]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
spi: 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 17:05:41 +0000 (19:05 +0200)
committerMark Brown <broonie@kernel.org>
Fri, 22 May 2026 11:12:11 +0000 (12:12 +0100)
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 these arrays, drop a comma after 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>
Link: https://patch.msgid.link/20260518170542.807843-2-u.kleine-koenig@baylibre.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-sc18is602.c
drivers/spi/spi-xcomm.c

index 78c558e7228ecef809d03efccf787a84f5ed7128..ae534ebd5e8739292c5d5e597867097738447925 100644 (file)
@@ -295,9 +295,9 @@ static int sc18is602_probe(struct i2c_client *client)
 }
 
 static const struct i2c_device_id sc18is602_id[] = {
-       { "sc18is602", sc18is602 },
-       { "sc18is602b", sc18is602b },
-       { "sc18is603", sc18is603 },
+       { .name = "sc18is602", .driver_data = sc18is602 },
+       { .name = "sc18is602b", .driver_data = sc18is602b },
+       { .name = "sc18is603", .driver_data = sc18is603 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, sc18is602_id);
index 130a3d716dd4cd8b34231972fc5b566c7a8cbfea..e40ec6ebe4e5587e487f00aa30fb5c61ab1e41e3 100644 (file)
@@ -269,8 +269,8 @@ static int spi_xcomm_probe(struct i2c_client *i2c)
 }
 
 static const struct i2c_device_id spi_xcomm_ids[] = {
-       { "spi-xcomm" },
-       { },
+       { .name = "spi-xcomm" },
+       { }
 };
 MODULE_DEVICE_TABLE(i2c, spi_xcomm_ids);