[PATCH v2 16/23] mfd: Use named initializers for platform_device_id array
Uwe Kleine-König (The Capable Hub)
u.kleine-koenig at baylibre.com
Wed Jul 8 04:15:23 PDT 2026
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.
Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig at baylibre.com>
---
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 f0bc0b5a6f4a..7c00c71ca4ba 100644
--- a/drivers/mfd/ab8500-core.c
+++ b/drivers/mfd/ab8500-core.c
@@ -1250,10 +1250,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 a933cb936da6..baa6487abf9e 100644
--- a/drivers/mfd/cros_ec_dev.c
+++ b/drivers/mfd/cros_ec_dev.c
@@ -375,7 +375,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 7987583afc60..7bbd9b730b75 100644
--- a/drivers/mfd/mt6397-core.c
+++ b/drivers/mfd/mt6397-core.c
@@ -429,8 +429,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.55.0.11.g153666a7d9bb
More information about the Linux-mediatek
mailing list