i2c: Use named initializers for arrays of i2c_device_data

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>
This commit is contained in:
Uwe Kleine-König (The Capable Hub)
2026-05-18 18:45:09 +02:00
committed by Andi Shyti
parent fae5e96bb6
commit 2d61e7cf4d
7 changed files with 34 additions and 34 deletions

View 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" },
{ }
};

View 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);

View 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);

View 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);

View 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);

View File

@@ -74,8 +74,8 @@ struct pca9541 {
};
static const struct i2c_device_id pca9541_id[] = {
{ "pca9541" },
{}
{ .name = "pca9541" },
{ }
};
MODULE_DEVICE_TABLE(i2c, pca9541_id);

View 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);