Subject: Re: [PATCH v2 2/2] regulator: Use named initializers for arrays of i2c_device_data

From: Laurent Pinchart <[email-masked]>
Date: Tue, 19 May 2026 12:07:00 +0200

On Tue, May 19, 2026 at 11:57:51AM +0200, Uwe Kleine-König (The Capable Hub) wrote:
> While being less compact, using named initializers allows to more easily
> see which members of the structs are assigned which value without having
> to lookup the declaration of the struct. And it's also more robust
> against changes to the struct definition.
> 
> The mentioned robustness is relevant for a planned change to struct
> i2c_device_id that replaces .driver_data by an anonymous union.
> 
> While touching all these arrays, unify usage of whitespace and commas.
> 
> This patch doesn't modify the compiled arrays, only their representation
> in source form benefits. The former was confirmed with x86 and arm64
> builds.
> 
> Signed-off-by: Uwe Kleine-König (The Capable Hub) <[email-masked]>
> ---
>  drivers/regulator/88pg86x.c            |  4 +--
>  drivers/regulator/ad5398.c             |  4 +--
>  drivers/regulator/da9121-regulator.c   | 20 +++++++--------
>  drivers/regulator/da9210-regulator.c   |  4 +--
>  drivers/regulator/da9211-regulator.c   | 18 +++++++-------
>  drivers/regulator/fan53880.c           |  4 +--
>  drivers/regulator/isl9305.c            |  4 +--
>  drivers/regulator/lp3971.c             |  2 +-
>  drivers/regulator/lp3972.c             |  2 +-
>  drivers/regulator/lp872x.c             | 34 +++++++++++++-------------
>  drivers/regulator/lp8755.c             |  4 +--
>  drivers/regulator/ltc3589.c            |  6 ++---
>  drivers/regulator/ltc3676.c            |  2 +-
>  drivers/regulator/max1586.c            |  2 +-
>  drivers/regulator/max20086-regulator.c |  8 +++---
>  drivers/regulator/max20411-regulator.c |  2 +-
>  drivers/regulator/max77503-regulator.c |  2 +-
>  drivers/regulator/max77675-regulator.c |  2 +-
>  drivers/regulator/max77826-regulator.c |  2 +-
>  drivers/regulator/max77838-regulator.c |  2 +-
>  drivers/regulator/max77857-regulator.c |  8 +++---
>  drivers/regulator/max8649.c            |  2 +-
>  drivers/regulator/max8893.c            |  2 +-
>  drivers/regulator/max8952.c            |  2 +-
>  drivers/regulator/mcp16502.c           |  2 +-
>  drivers/regulator/mp5416.c             |  6 ++---
>  drivers/regulator/mp8859.c             |  4 +--
>  drivers/regulator/mp886x.c             |  6 ++---
>  drivers/regulator/mpq7920.c            |  4 +--
>  drivers/regulator/mt6311-regulator.c   |  4 +--
>  drivers/regulator/pf530x-regulator.c   |  6 ++---
>  drivers/regulator/pf8x00-regulator.c   |  8 +++---
>  drivers/regulator/pv88060-regulator.c  |  4 +--
>  drivers/regulator/pv88080-regulator.c  |  8 +++---
>  drivers/regulator/pv88090-regulator.c  |  4 +--
>  drivers/regulator/slg51000-regulator.c |  4 +--
>  drivers/regulator/sy8106a-regulator.c  |  2 +-
>  drivers/regulator/sy8824x.c            |  8 +++---
>  drivers/regulator/sy8827n.c            |  4 +--
>  drivers/regulator/tps6286x-regulator.c | 10 ++++----
>  drivers/regulator/tps6287x-regulator.c | 10 ++++----
>  41 files changed, 118 insertions(+), 118 deletions(-)

[snip]

> diff --git a/drivers/regulator/lp872x.c b/drivers/regulator/lp872x.c
> index 942f37082cb1..779df653338a 100644
> --- a/drivers/regulator/lp872x.c
> +++ b/drivers/regulator/lp872x.c
> @@ -796,24 +796,24 @@ static const struct regmap_config lp872x_regmap_config = {
>  #define LP872X_VALID_OPMODE	(REGULATOR_MODE_FAST | REGULATOR_MODE_NORMAL)
>  
>  static struct of_regulator_match lp8720_matches[] = {

This is unrelated to the commit message that only mentions
i2c_device_id.

With this chunk dropped,

Reviewed-by: Laurent Pinchart <[email-masked]>

> -	{ .name = "ldo1", .driver_data = (void *)LP8720_ID_LDO1, },
> -	{ .name = "ldo2", .driver_data = (void *)LP8720_ID_LDO2, },
> -	{ .name = "ldo3", .driver_data = (void *)LP8720_ID_LDO3, },
> -	{ .name = "ldo4", .driver_data = (void *)LP8720_ID_LDO4, },
> -	{ .name = "ldo5", .driver_data = (void *)LP8720_ID_LDO5, },
> -	{ .name = "buck", .driver_data = (void *)LP8720_ID_BUCK, },
> +	{ .name = "ldo1", .driver_data = (void *)LP8720_ID_LDO1 },
> +	{ .name = "ldo2", .driver_data = (void *)LP8720_ID_LDO2 },
> +	{ .name = "ldo3", .driver_data = (void *)LP8720_ID_LDO3 },
> +	{ .name = "ldo4", .driver_data = (void *)LP8720_ID_LDO4 },
> +	{ .name = "ldo5", .driver_data = (void *)LP8720_ID_LDO5 },
> +	{ .name = "buck", .driver_data = (void *)LP8720_ID_BUCK },
>  };
>  
>  static struct of_regulator_match lp8725_matches[] = {
> -	{ .name = "ldo1", .driver_data = (void *)LP8725_ID_LDO1, },
> -	{ .name = "ldo2", .driver_data = (void *)LP8725_ID_LDO2, },
> -	{ .name = "ldo3", .driver_data = (void *)LP8725_ID_LDO3, },
> -	{ .name = "ldo4", .driver_data = (void *)LP8725_ID_LDO4, },
> -	{ .name = "ldo5", .driver_data = (void *)LP8725_ID_LDO5, },
> -	{ .name = "lilo1", .driver_data = (void *)LP8725_ID_LILO1, },
> -	{ .name = "lilo2", .driver_data = (void *)LP8725_ID_LILO2, },
> -	{ .name = "buck1", .driver_data = (void *)LP8725_ID_BUCK1, },
> -	{ .name = "buck2", .driver_data = (void *)LP8725_ID_BUCK2, },
> +	{ .name = "ldo1", .driver_data = (void *)LP8725_ID_LDO1 },
> +	{ .name = "ldo2", .driver_data = (void *)LP8725_ID_LDO2 },
> +	{ .name = "ldo3", .driver_data = (void *)LP8725_ID_LDO3 },
> +	{ .name = "ldo4", .driver_data = (void *)LP8725_ID_LDO4 },
> +	{ .name = "ldo5", .driver_data = (void *)LP8725_ID_LDO5 },
> +	{ .name = "lilo1", .driver_data = (void *)LP8725_ID_LILO1 },
> +	{ .name = "lilo2", .driver_data = (void *)LP8725_ID_LILO2 },
> +	{ .name = "buck1", .driver_data = (void *)LP8725_ID_BUCK1 },
> +	{ .name = "buck2", .driver_data = (void *)LP8725_ID_BUCK2 },
>  };
>  
>  static struct lp872x_platform_data
> @@ -935,8 +935,8 @@ static const struct of_device_id lp872x_dt_ids[] __maybe_unused = {
>  MODULE_DEVICE_TABLE(of, lp872x_dt_ids);
>  
>  static const struct i2c_device_id lp872x_ids[] = {
> -	{"lp8720", LP8720},
> -	{"lp8725", LP8725},
> +	{ .name = "lp8720", .driver_data = LP8720 },
> +	{ .name = "lp8725", .driver_data = LP8725 },
>  	{ }
>  };
>  MODULE_DEVICE_TABLE(i2c, lp872x_ids);

[snip]

-- 
Regards,

Laurent Pinchart