]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
i2c: Use named initializers for arrays of i2c_device_data
authorUwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
Mon, 18 May 2026 16:45:09 +0000 (18:45 +0200)
committerAndi Shyti <andi.shyti@kernel.org>
Thu, 4 Jun 2026 23:09:25 +0000 (01:09 +0200)
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 in the list
terminator.

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) <u.kleine-koenig@baylibre.com>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Link: https://lore.kernel.org/r/20260518164510.805502-2-u.kleine-koenig@baylibre.com
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
drivers/i2c/i2c-core-base.c
drivers/i2c/i2c-slave-eeprom.c
drivers/i2c/i2c-slave-testunit.c
drivers/i2c/i2c-smbus.c
drivers/i2c/muxes/i2c-mux-ltc4306.c
drivers/i2c/muxes/i2c-mux-pca9541.c
drivers/i2c/muxes/i2c-mux-pca954x.c

index 9c46147e3506d15d53b9b7d6b592709de56e41b9..7e4b7adffd6e4ababa4dc16e8d68cc923c9b4e64 100644 (file)
@@ -1107,8 +1107,8 @@ EXPORT_SYMBOL(i2c_find_device_by_fwnode);
 
 
 static const struct i2c_device_id dummy_id[] = {
-       { "dummy", },
-       { "smbus_host_notify", },
+       { .name = "dummy" },
+       { .name = "smbus_host_notify" },
        { }
 };
 
index 6bc2ef650a74eb61f36ff7e3adac5f7709213085..226d722af66227067252771129b3cf3a9b7d80eb 100644 (file)
@@ -191,14 +191,14 @@ static void i2c_slave_eeprom_remove(struct i2c_client *client)
 }
 
 static const struct i2c_device_id i2c_slave_eeprom_id[] = {
-       { "slave-24c02", I2C_SLAVE_DEVICE_MAGIC(2048 / 8,  0) },
-       { "slave-24c02ro", I2C_SLAVE_DEVICE_MAGIC(2048 / 8,  I2C_SLAVE_FLAG_RO) },
-       { "slave-24c32", I2C_SLAVE_DEVICE_MAGIC(32768 / 8, I2C_SLAVE_FLAG_ADDR16) },
-       { "slave-24c32ro", I2C_SLAVE_DEVICE_MAGIC(32768 / 8, I2C_SLAVE_FLAG_ADDR16 | I2C_SLAVE_FLAG_RO) },
-       { "slave-24c64", I2C_SLAVE_DEVICE_MAGIC(65536 / 8, I2C_SLAVE_FLAG_ADDR16) },
-       { "slave-24c64ro", I2C_SLAVE_DEVICE_MAGIC(65536 / 8, I2C_SLAVE_FLAG_ADDR16 | I2C_SLAVE_FLAG_RO) },
-       { "slave-24c512", I2C_SLAVE_DEVICE_MAGIC(524288 / 8, I2C_SLAVE_FLAG_ADDR16) },
-       { "slave-24c512ro", I2C_SLAVE_DEVICE_MAGIC(524288 / 8, I2C_SLAVE_FLAG_ADDR16 | I2C_SLAVE_FLAG_RO) },
+       { .name = "slave-24c02", .driver_data = I2C_SLAVE_DEVICE_MAGIC(2048 / 8,  0) },
+       { .name = "slave-24c02ro", .driver_data = I2C_SLAVE_DEVICE_MAGIC(2048 / 8,  I2C_SLAVE_FLAG_RO) },
+       { .name = "slave-24c32", .driver_data = I2C_SLAVE_DEVICE_MAGIC(32768 / 8, I2C_SLAVE_FLAG_ADDR16) },
+       { .name = "slave-24c32ro", .driver_data = I2C_SLAVE_DEVICE_MAGIC(32768 / 8, I2C_SLAVE_FLAG_ADDR16 | I2C_SLAVE_FLAG_RO) },
+       { .name = "slave-24c64", .driver_data = I2C_SLAVE_DEVICE_MAGIC(65536 / 8, I2C_SLAVE_FLAG_ADDR16) },
+       { .name = "slave-24c64ro", .driver_data = I2C_SLAVE_DEVICE_MAGIC(65536 / 8, I2C_SLAVE_FLAG_ADDR16 | I2C_SLAVE_FLAG_RO) },
+       { .name = "slave-24c512", .driver_data = I2C_SLAVE_DEVICE_MAGIC(524288 / 8, I2C_SLAVE_FLAG_ADDR16) },
+       { .name = "slave-24c512ro", .driver_data = I2C_SLAVE_DEVICE_MAGIC(524288 / 8, I2C_SLAVE_FLAG_ADDR16 | I2C_SLAVE_FLAG_RO) },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, i2c_slave_eeprom_id);
index 6de4307050dde6d9670b4bef83c202a57eb44c99..68a07d957113ba0a3f9a85d77f4b94c476b9ee3a 100644 (file)
@@ -270,7 +270,7 @@ static void i2c_slave_testunit_remove(struct i2c_client *client)
 }
 
 static const struct i2c_device_id i2c_slave_testunit_id[] = {
-       { "slave-testunit" },
+       { .name = "slave-testunit" },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, i2c_slave_testunit_id);
index bc7bd55e6370547045a74f83fdd7492f851f74f7..069f08f68bc15e77479ea30ee1903c2c5e8673db 100644 (file)
@@ -220,7 +220,7 @@ static void smbalert_remove(struct i2c_client *ara)
 }
 
 static const struct i2c_device_id smbalert_ids[] = {
-       { "smbus_alert" },
+       { .name = "smbus_alert" },
        { /* LIST END */ }
 };
 MODULE_DEVICE_TABLE(i2c, smbalert_ids);
index 50fbc0d06e62b2743dd7f20c9863d56009dcf0e9..18228f5b80e832d8ba9e873ab781f6aad66a1068 100644 (file)
@@ -191,8 +191,8 @@ static int ltc4306_deselect_mux(struct i2c_mux_core *muxc, u32 chan)
 }
 
 static const struct i2c_device_id ltc4306_id[] = {
-       { "ltc4305", ltc_4305 },
-       { "ltc4306", ltc_4306 },
+       { .name = "ltc4305", .driver_data = ltc_4305 },
+       { .name = "ltc4306", .driver_data = ltc_4306 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, ltc4306_id);
index 3d8002caf7031bc52a6e83c64677b7906ccde606..9a59129bc50f65c43b296bc5d48c7775f710f6cb 100644 (file)
@@ -74,8 +74,8 @@ struct pca9541 {
 };
 
 static const struct i2c_device_id pca9541_id[] = {
-       { "pca9541" },
-       {}
+       { .name = "pca9541" },
+       { }
 };
 
 MODULE_DEVICE_TABLE(i2c, pca9541_id);
index b9f370c9f018c2b065888869e8218399b875f5eb..8fca709ed279b1cdc1541896bcfc9b39b630a140 100644 (file)
@@ -250,24 +250,24 @@ static const struct chip_desc chips[] = {
 };
 
 static const struct i2c_device_id pca954x_id[] = {
-       { "max7356", max_7356 },
-       { "max7357", max_7357 },
-       { "max7358", max_7358 },
-       { "max7367", max_7367 },
-       { "max7368", max_7368 },
-       { "max7369", max_7369 },
-       { "pca9540", pca_9540 },
-       { "pca9542", pca_9542 },
-       { "pca9543", pca_9543 },
-       { "pca9544", pca_9544 },
-       { "pca9545", pca_9545 },
-       { "pca9546", pca_9546 },
-       { "pca9547", pca_9547 },
-       { "pca9548", pca_9548 },
-       { "pca9846", pca_9846 },
-       { "pca9847", pca_9847 },
-       { "pca9848", pca_9848 },
-       { "pca9849", pca_9849 },
+       { .name = "max7356", .driver_data = max_7356 },
+       { .name = "max7357", .driver_data = max_7357 },
+       { .name = "max7358", .driver_data = max_7358 },
+       { .name = "max7367", .driver_data = max_7367 },
+       { .name = "max7368", .driver_data = max_7368 },
+       { .name = "max7369", .driver_data = max_7369 },
+       { .name = "pca9540", .driver_data = pca_9540 },
+       { .name = "pca9542", .driver_data = pca_9542 },
+       { .name = "pca9543", .driver_data = pca_9543 },
+       { .name = "pca9544", .driver_data = pca_9544 },
+       { .name = "pca9545", .driver_data = pca_9545 },
+       { .name = "pca9546", .driver_data = pca_9546 },
+       { .name = "pca9547", .driver_data = pca_9547 },
+       { .name = "pca9548", .driver_data = pca_9548 },
+       { .name = "pca9846", .driver_data = pca_9846 },
+       { .name = "pca9847", .driver_data = pca_9847 },
+       { .name = "pca9848", .driver_data = pca_9848 },
+       { .name = "pca9849", .driver_data = pca_9849 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, pca954x_id);