[PATCH v4 15/20] mfd: Use named initializers for platform_device_id array

From: Uwe Kleine-König (The Capable Hub)

Date: Tue Nov 10 2026 - 17:00:51 EST


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
platform_device_id that replaces .driver_data by an anonymous union.

This patch doesn't modify the compiled arrays, only their representation
in source form benefits.

Also drop a tailing comma after a list terminator to match the common
style for these device-id arrays.

Reviewed-by: Linus Walleij <linusw@xxxxxxxxxx>
Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@xxxxxxxxxxxx>
---
drivers/mfd/ab8500-core.c | 8 ++++----
drivers/mfd/cros_ec_dev.c | 2 +-
drivers/mfd/mt6397-core.c | 4 ++--
3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c
index d5602b2f4a0e..8638fc8472f7 100644
--- a/drivers/mfd/ab8500-core.c
+++ b/drivers/mfd/ab8500-core.c
@@ -1252,10 +1252,10 @@ static int ab8500_probe(struct platform_device *pdev)
}

static const struct platform_device_id ab8500_id[] = {
- { "ab8500-core", AB8500_VERSION_AB8500 },
- { "ab8505-core", AB8500_VERSION_AB8505 },
- { "ab9540-i2c", AB8500_VERSION_AB9540 },
- { "ab8540-i2c", AB8500_VERSION_AB8540 },
+ { .name = "ab8500-core", .driver_data = AB8500_VERSION_AB8500 },
+ { .name = "ab8505-core", .driver_data = AB8500_VERSION_AB8505 },
+ { .name = "ab9540-i2c", .driver_data = AB8500_VERSION_AB9540 },
+ { .name = "ab8540-i2c", .driver_data = AB8500_VERSION_AB8540 },
{ }
};

diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c
index 96aac158fd8b..3c7e7f1efd0f 100644
--- a/drivers/mfd/cros_ec_dev.c
+++ b/drivers/mfd/cros_ec_dev.c
@@ -379,7 +379,7 @@ static void ec_device_remove(struct platform_device *pdev)
}

static const struct platform_device_id cros_ec_id[] = {
- { DRV_NAME },
+ { .name = DRV_NAME },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(platform, cros_ec_id);
diff --git a/drivers/mfd/mt6397-core.c b/drivers/mfd/mt6397-core.c
index e74936ac206f..385121867da5 100644
--- a/drivers/mfd/mt6397-core.c
+++ b/drivers/mfd/mt6397-core.c
@@ -435,8 +435,8 @@ static const struct of_device_id mt6397_of_match[] = {
MODULE_DEVICE_TABLE(of, mt6397_of_match);

static const struct platform_device_id mt6397_id[] = {
- { "mt6397" },
- { },
+ { .name = "mt6397" },
+ { }
};
MODULE_DEVICE_TABLE(platform, mt6397_id);

--
2.56.0.rc1