* [PATCH v1 0/6] power: Use named initializers for platform_device_id arrays
@ 2026-05-29 10:18 Uwe Kleine-König (The Capable Hub)
2026-05-29 10:18 ` [PATCH v1 1/6] power: Drop unused assignment of platform_device_id driver data Uwe Kleine-König (The Capable Hub)
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-05-29 10:18 UTC (permalink / raw)
To: Sebastian Reichel
Cc: Kuan-Wei Chiu, Benson Leung, Guenter Roeck, Thomas Weißschuh,
Krzysztof Kozlowski, Matthias Brugger, AngeloGioacchino Del Regno,
linux-pm, linux-kernel, chrome-platform, linux-arm-kernel,
linux-mediatek, Hans de Goede, Marek Szyprowski,
Sebastian Krzyszkowiak, Purism Kernel Team, Yixun Lan,
Andreas Kemnade, Matti Vaittinen, Sven Peter, Janne Grunau,
Neal Gompa, Amit Sunil Dhamne, Samuel Kayode, linux-riscv,
spacemit, asahi, imx, Chen-Yu Tsai
Hello,
this series targets to use named initializers for platform_device_id
arrays. In general these are better readable for humans and more robust
to changes in the respective struct definition.
This robustness is needed as I want to do
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -610,4 +610,7 @@ struct dmi_system_id {
struct platform_device_id {
char name[PLATFORM_NAME_SIZE];
- kernel_ulong_t driver_data;
+ union {
+ kernel_ulong_t driver_data;
+ const void *driver_data_ptr;
+ };
};
which allows dropping several casts and eases porting CHERI to mainline
linux. A possible follow-up change is the following example:
diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
index 5d61053e0596..03bc8e859d73 100644
--- a/drivers/gpio/gpio-pxa.c
+++ b/drivers/gpio/gpio-pxa.c
@@ -534,7 +534,7 @@ static struct irq_chip pxa_muxed_gpio_chip = {
static int pxa_gpio_nums(struct platform_device *pdev)
{
const struct platform_device_id *id = platform_get_device_id(pdev);
- struct pxa_gpio_id *pxa_id = (struct pxa_gpio_id *)id->driver_data;
+ struct pxa_gpio_id *pxa_id = id->driver_data_ptr;
int count = 0;
switch (pxa_id->type) {
@@ -708,14 +708,14 @@ static int pxa_gpio_probe(struct platform_device *pdev)
}
static const struct platform_device_id gpio_id_table[] = {
- { .name = "pxa25x-gpio", .driver_data = (unsigned long)&pxa25x_id },
- { .name = "pxa26x-gpio", .driver_data = (unsigned long)&pxa26x_id },
- { .name = "pxa27x-gpio", .driver_data = (unsigned long)&pxa27x_id },
- { .name = "pxa3xx-gpio", .driver_data = (unsigned long)&pxa3xx_id },
- { .name = "pxa93x-gpio", .driver_data = (unsigned long)&pxa93x_id },
- { .name = "mmp-gpio", .driver_data = (unsigned long)&mmp_id },
- { .name = "mmp2-gpio", .driver_data = (unsigned long)&mmp2_id },
- { .name = "pxa1928-gpio", .driver_data = (unsigned long)&pxa1928_id },
+ { .name = "pxa25x-gpio", .driver_data_ptr = &pxa25x_id },
+ { .name = "pxa26x-gpio", .driver_data_ptr = &pxa26x_id },
+ { .name = "pxa27x-gpio", .driver_data_ptr = &pxa27x_id },
+ { .name = "pxa3xx-gpio", .driver_data_ptr = &pxa3xx_id },
+ { .name = "pxa93x-gpio", .driver_data_ptr = &pxa93x_id },
+ { .name = "mmp-gpio", .driver_data_ptr = &mmp_id },
+ { .name = "mmp2-gpio", .driver_data_ptr = &mmp2_id },
+ { .name = "pxa1928-gpio", .driver_data_ptr = &pxa1928_id },
{ }
};
increasing readability due to less casting. Also this results in the
compiler warning:
drivers/gpio/gpio-pxa.c: In function ‘pxa_gpio_nums’:
drivers/gpio/gpio-pxa.c:537:38: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
537 | struct pxa_gpio_id *pxa_id = id->driver_data_ptr;
| ^~
which is a good thing as adding the needed const to fix this warning
improves type safety. (Sorry, no driver below drivers/power benefits
here, so the example is from a different subsystem.)
Patch #5 is just an unrelated change where I spotted the patch
opportunity while preparing this series. It's included here just for my
convenience and could be applied independently.
If you consider the last patch mostly churn, just drop it.
There are no dependencies between the patches, the only file that is
touched in more than one patch is drivers/power/supply/mt6360_charger.c
and even if these (i.e. patches #1 and #5) are reordered, git should be
able to cope with that without conflicts.
Note that this series is only build tested, and there is the possibility
that I failed to spot driver data usage that render patches #2 and/or #3
wrong. So a deeper look on at least those two won't hurt.
Best regards
Uwe
Uwe Kleine-König (The Capable Hub) (6):
power: Drop unused assignment of platform_device_id driver data
power: supply: max14577: Drop driver data in of and platform device id
arrays
power: supply: max17042: Drop driver data in of and platform device id
arrays
power: Use named initializers for platform_device_id arrays
power: supply: mt6360_charger: Use of match table unconditionally
power: Unify code style for platform_device_id arrays
drivers/power/reset/qemu-virt-ctrl.c | 2 +-
drivers/power/reset/spacemit-p1-reboot.c | 4 ++--
drivers/power/reset/tps65086-restart.c | 2 +-
drivers/power/supply/axp288_charger.c | 2 +-
drivers/power/supply/axp288_fuel_gauge.c | 2 +-
drivers/power/supply/bd71828-power.c | 8 ++++----
drivers/power/supply/charger-manager.c | 4 ++--
drivers/power/supply/cros_charge-control.c | 4 ++--
drivers/power/supply/cros_peripheral_charger.c | 4 ++--
drivers/power/supply/cros_usbpd-charger.c | 4 ++--
drivers/power/supply/macsmc-power.c | 2 +-
drivers/power/supply/max14577_charger.c | 12 +++++-------
drivers/power/supply/max17042_battery.c | 14 +++++++-------
drivers/power/supply/max77693_charger.c | 2 +-
drivers/power/supply/max77759_charger.c | 2 +-
drivers/power/supply/max8997_charger.c | 2 +-
drivers/power/supply/max8998_charger.c | 2 +-
drivers/power/supply/mt6360_charger.c | 6 +++---
drivers/power/supply/pf1550-charger.c | 2 +-
drivers/power/supply/rt5033_charger.c | 2 +-
20 files changed, 40 insertions(+), 42 deletions(-)
base-commit: f7af91adc230aa99e23330ecf85bc9badd9780ad
--
2.47.3
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v1 1/6] power: Drop unused assignment of platform_device_id driver data
2026-05-29 10:18 [PATCH v1 0/6] power: Use named initializers for platform_device_id arrays Uwe Kleine-König (The Capable Hub)
@ 2026-05-29 10:18 ` Uwe Kleine-König (The Capable Hub)
2026-05-29 22:02 ` Tzung-Bi Shih
2026-05-29 10:18 ` [PATCH v1 5/6] power: supply: mt6360_charger: Use of match table unconditionally Uwe Kleine-König (The Capable Hub)
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-05-29 10:18 UTC (permalink / raw)
To: Sebastian Reichel
Cc: Kuan-Wei Chiu, Benson Leung, Guenter Roeck, Thomas Weißschuh,
Krzysztof Kozlowski, Matthias Brugger, AngeloGioacchino Del Regno,
linux-pm, linux-kernel, chrome-platform, linux-arm-kernel,
linux-mediatek
The driver explicitly set the .driver_data member of struct
platform_device_id to zero without relying on that value. Drop this
unused assignments.
While touching this array unify spacing, use a named initializer for
.name and drop trailing commas after the list terminators.
Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
---
drivers/power/reset/qemu-virt-ctrl.c | 2 +-
drivers/power/supply/charger-manager.c | 4 ++--
drivers/power/supply/cros_charge-control.c | 4 ++--
drivers/power/supply/cros_peripheral_charger.c | 4 ++--
drivers/power/supply/cros_usbpd-charger.c | 4 ++--
drivers/power/supply/max77693_charger.c | 2 +-
drivers/power/supply/max8997_charger.c | 2 +-
drivers/power/supply/mt6360_charger.c | 4 ++--
8 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/power/reset/qemu-virt-ctrl.c b/drivers/power/reset/qemu-virt-ctrl.c
index 01409dfe2265..aa8355270b2c 100644
--- a/drivers/power/reset/qemu-virt-ctrl.c
+++ b/drivers/power/reset/qemu-virt-ctrl.c
@@ -103,7 +103,7 @@ static int qemu_virt_ctrl_probe(struct platform_device *pdev)
}
static const struct platform_device_id qemu_virt_ctrl_id[] = {
- { "qemu-virt-ctrl", 0 },
+ { .name = "qemu-virt-ctrl" },
{ }
};
MODULE_DEVICE_TABLE(platform, qemu_virt_ctrl_id);
diff --git a/drivers/power/supply/charger-manager.c b/drivers/power/supply/charger-manager.c
index 1b0239c59114..fa7518e9d72f 100644
--- a/drivers/power/supply/charger-manager.c
+++ b/drivers/power/supply/charger-manager.c
@@ -1649,8 +1649,8 @@ static void charger_manager_remove(struct platform_device *pdev)
}
static const struct platform_device_id charger_manager_id[] = {
- { "charger-manager", 0 },
- { },
+ { .name = "charger-manager" },
+ { }
};
MODULE_DEVICE_TABLE(platform, charger_manager_id);
diff --git a/drivers/power/supply/cros_charge-control.c b/drivers/power/supply/cros_charge-control.c
index 53e6a77e03fc..b489325be816 100644
--- a/drivers/power/supply/cros_charge-control.c
+++ b/drivers/power/supply/cros_charge-control.c
@@ -320,8 +320,8 @@ static int cros_chctl_probe(struct platform_device *pdev)
}
static const struct platform_device_id cros_chctl_id[] = {
- { "cros-charge-control", 0 },
- {}
+ { .name = "cros-charge-control" },
+ { }
};
static struct platform_driver cros_chctl_driver = {
diff --git a/drivers/power/supply/cros_peripheral_charger.c b/drivers/power/supply/cros_peripheral_charger.c
index f132fad288cb..9f67a6dbd94e 100644
--- a/drivers/power/supply/cros_peripheral_charger.c
+++ b/drivers/power/supply/cros_peripheral_charger.c
@@ -369,8 +369,8 @@ static int __maybe_unused cros_pchg_resume(struct device *dev)
static SIMPLE_DEV_PM_OPS(cros_pchg_pm_ops, NULL, cros_pchg_resume);
static const struct platform_device_id cros_pchg_id[] = {
- { DRV_NAME, 0 },
- {}
+ { .name = DRV_NAME },
+ { }
};
MODULE_DEVICE_TABLE(platform, cros_pchg_id);
diff --git a/drivers/power/supply/cros_usbpd-charger.c b/drivers/power/supply/cros_usbpd-charger.c
index 7d3e676a951c..308e1d4e6dd8 100644
--- a/drivers/power/supply/cros_usbpd-charger.c
+++ b/drivers/power/supply/cros_usbpd-charger.c
@@ -707,8 +707,8 @@ static SIMPLE_DEV_PM_OPS(cros_usbpd_charger_pm_ops, NULL,
cros_usbpd_charger_resume);
static const struct platform_device_id cros_usbpd_charger_id[] = {
- { DRV_NAME, 0 },
- {}
+ { .name = DRV_NAME },
+ { }
};
MODULE_DEVICE_TABLE(platform, cros_usbpd_charger_id);
diff --git a/drivers/power/supply/max77693_charger.c b/drivers/power/supply/max77693_charger.c
index 027d6a539b65..76c58b32a374 100644
--- a/drivers/power/supply/max77693_charger.c
+++ b/drivers/power/supply/max77693_charger.c
@@ -788,7 +788,7 @@ static void max77693_charger_remove(struct platform_device *pdev)
}
static const struct platform_device_id max77693_charger_id[] = {
- { "max77693-charger", 0, },
+ { .name = "max77693-charger" },
{ }
};
MODULE_DEVICE_TABLE(platform, max77693_charger_id);
diff --git a/drivers/power/supply/max8997_charger.c b/drivers/power/supply/max8997_charger.c
index 1ec3535a257d..19da9eff0372 100644
--- a/drivers/power/supply/max8997_charger.c
+++ b/drivers/power/supply/max8997_charger.c
@@ -268,7 +268,7 @@ static int max8997_battery_probe(struct platform_device *pdev)
}
static const struct platform_device_id max8997_battery_id[] = {
- { "max8997-battery", 0 },
+ { .name = "max8997-battery" },
{ }
};
MODULE_DEVICE_TABLE(platform, max8997_battery_id);
diff --git a/drivers/power/supply/mt6360_charger.c b/drivers/power/supply/mt6360_charger.c
index 77747eb51667..69955f255091 100644
--- a/drivers/power/supply/mt6360_charger.c
+++ b/drivers/power/supply/mt6360_charger.c
@@ -841,8 +841,8 @@ static const struct of_device_id __maybe_unused mt6360_charger_of_id[] = {
MODULE_DEVICE_TABLE(of, mt6360_charger_of_id);
static const struct platform_device_id mt6360_charger_id[] = {
- { "mt6360-chg", 0 },
- {},
+ { .name = "mt6360-chg" },
+ { }
};
MODULE_DEVICE_TABLE(platform, mt6360_charger_id);
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v1 5/6] power: supply: mt6360_charger: Use of match table unconditionally
2026-05-29 10:18 [PATCH v1 0/6] power: Use named initializers for platform_device_id arrays Uwe Kleine-König (The Capable Hub)
2026-05-29 10:18 ` [PATCH v1 1/6] power: Drop unused assignment of platform_device_id driver data Uwe Kleine-König (The Capable Hub)
@ 2026-05-29 10:18 ` Uwe Kleine-König (The Capable Hub)
2026-06-03 20:46 ` (subset) [PATCH v1 0/6] power: Use named initializers for platform_device_id arrays Sebastian Reichel
2026-06-26 8:20 ` patchwork-bot+linux-riscv
3 siblings, 0 replies; 6+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-05-29 10:18 UTC (permalink / raw)
To: Sebastian Reichel
Cc: Matthias Brugger, AngeloGioacchino Del Regno, linux-pm,
linux-kernel, linux-arm-kernel, linux-mediatek
mt6360_charger_of_id is defined unconditionally, so it doesn't make sense
to not use it for the driver's .of_match_table member.
Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
---
drivers/power/supply/mt6360_charger.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/power/supply/mt6360_charger.c b/drivers/power/supply/mt6360_charger.c
index 69955f255091..d3b0731f6562 100644
--- a/drivers/power/supply/mt6360_charger.c
+++ b/drivers/power/supply/mt6360_charger.c
@@ -849,7 +849,7 @@ MODULE_DEVICE_TABLE(platform, mt6360_charger_id);
static struct platform_driver mt6360_charger_driver = {
.driver = {
.name = "mt6360-chg",
- .of_match_table = of_match_ptr(mt6360_charger_of_id),
+ .of_match_table = mt6360_charger_of_id,
},
.probe = mt6360_charger_probe,
.id_table = mt6360_charger_id,
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/6] power: Drop unused assignment of platform_device_id driver data
2026-05-29 10:18 ` [PATCH v1 1/6] power: Drop unused assignment of platform_device_id driver data Uwe Kleine-König (The Capable Hub)
@ 2026-05-29 22:02 ` Tzung-Bi Shih
0 siblings, 0 replies; 6+ messages in thread
From: Tzung-Bi Shih @ 2026-05-29 22:02 UTC (permalink / raw)
To: Uwe Kleine-König (The Capable Hub)
Cc: Sebastian Reichel, Kuan-Wei Chiu, Benson Leung, Guenter Roeck,
Thomas Weißschuh, Krzysztof Kozlowski, Matthias Brugger,
AngeloGioacchino Del Regno, linux-pm, linux-kernel,
chrome-platform, linux-arm-kernel, linux-mediatek
On Fri, May 29, 2026 at 12:18:16PM +0200, Uwe Kleine-König (The Capable Hub) wrote:
> The driver explicitly set the .driver_data member of struct
> platform_device_id to zero without relying on that value. Drop this
> unused assignments.
>
> While touching this array unify spacing, use a named initializer for
> .name and drop trailing commas after the list terminators.
>
> Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: (subset) [PATCH v1 0/6] power: Use named initializers for platform_device_id arrays
2026-05-29 10:18 [PATCH v1 0/6] power: Use named initializers for platform_device_id arrays Uwe Kleine-König (The Capable Hub)
2026-05-29 10:18 ` [PATCH v1 1/6] power: Drop unused assignment of platform_device_id driver data Uwe Kleine-König (The Capable Hub)
2026-05-29 10:18 ` [PATCH v1 5/6] power: supply: mt6360_charger: Use of match table unconditionally Uwe Kleine-König (The Capable Hub)
@ 2026-06-03 20:46 ` Sebastian Reichel
2026-06-26 8:20 ` patchwork-bot+linux-riscv
3 siblings, 0 replies; 6+ messages in thread
From: Sebastian Reichel @ 2026-06-03 20:46 UTC (permalink / raw)
To: Sebastian Reichel, Uwe Kleine-König (The Capable Hub)
Cc: Kuan-Wei Chiu, Benson Leung, Guenter Roeck, Thomas Weißschuh,
Krzysztof Kozlowski, Matthias Brugger, AngeloGioacchino Del Regno,
linux-pm, linux-kernel, chrome-platform, linux-arm-kernel,
linux-mediatek, Hans de Goede, Marek Szyprowski,
Sebastian Krzyszkowiak, Purism Kernel Team, Yixun Lan,
Andreas Kemnade, Matti Vaittinen, Sven Peter, Janne Grunau,
Neal Gompa, Amit Sunil Dhamne, Samuel Kayode, linux-riscv,
spacemit, asahi, imx, Chen-Yu Tsai
On Fri, 29 May 2026 12:18:15 +0200, Uwe Kleine-König (The Capable Hub) wrote:
> this series targets to use named initializers for platform_device_id
> arrays. In general these are better readable for humans and more robust
> to changes in the respective struct definition.
>
> This robustness is needed as I want to do
>
> diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
> --- a/include/linux/mod_devicetable.h
> +++ b/include/linux/mod_devicetable.h
> @@ -610,4 +610,7 @@ struct dmi_system_id {
> struct platform_device_id {
> char name[PLATFORM_NAME_SIZE];
> - kernel_ulong_t driver_data;
> + union {
> + kernel_ulong_t driver_data;
> + const void *driver_data_ptr;
> + };
> };
>
> [...]
Applied, thanks!
[1/6] power: Drop unused assignment of platform_device_id driver data
commit: 75a0e1e0b86078687c3c6a05107a98c7e59a65a8
[2/6] power: supply: max14577: Drop driver data in of and platform device id arrays
commit: 37258ad1f3a52ea442c32b3c92ad7146e74050c7
[4/6] power: Use named initializers for platform_device_id arrays
commit: e28f7498dd819878b8acacb89c4c073a646feea0
[5/6] power: supply: mt6360_charger: Use of match table unconditionally
commit: eb7ed650e5960fc303130704d1e29d18a7d0e1df
[6/6] power: Unify code style for platform_device_id arrays
commit: e3f669bed32287ae72c05a4ddab4a6687b0e62ca
Best regards,
--
Sebastian Reichel <sebastian.reichel@collabora.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 0/6] power: Use named initializers for platform_device_id arrays
2026-05-29 10:18 [PATCH v1 0/6] power: Use named initializers for platform_device_id arrays Uwe Kleine-König (The Capable Hub)
` (2 preceding siblings ...)
2026-06-03 20:46 ` (subset) [PATCH v1 0/6] power: Use named initializers for platform_device_id arrays Sebastian Reichel
@ 2026-06-26 8:20 ` patchwork-bot+linux-riscv
3 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+linux-riscv @ 2026-06-26 8:20 UTC (permalink / raw)
To: =?utf-8?q?Uwe_Kleine-K=C3=B6nig_=28The_Capable_Hub=29_=3Cu=2Ekleine-koenig?=,
=?utf-8?q?=40baylibre=2Ecom=3E?=
Cc: linux-riscv, sre, visitorckw, bleung, groeck, linux, krzk,
matthias.bgg, angelogioacchino.delregno, linux-pm, linux-kernel,
chrome-platform, linux-arm-kernel, linux-mediatek, hansg,
m.szyprowski, sebastian.krzyszkowiak, kernel, dlan, andreas,
mazziesaccount, sven, j, neal, amitsd, samkay014, spacemit, asahi,
imx, wens
Hello:
This patch was applied to riscv/linux.git (fixes)
by Sebastian Reichel <sebastian.reichel@collabora.com>:
On Fri, 29 May 2026 12:18:15 +0200 you wrote:
> Hello,
>
> this series targets to use named initializers for platform_device_id
> arrays. In general these are better readable for humans and more robust
> to changes in the respective struct definition.
>
> This robustness is needed as I want to do
>
> [...]
Here is the summary with links:
- [v1,4/6] power: Use named initializers for platform_device_id arrays
https://git.kernel.org/riscv/c/e28f7498dd81
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-06-26 8:21 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-29 10:18 [PATCH v1 0/6] power: Use named initializers for platform_device_id arrays Uwe Kleine-König (The Capable Hub)
2026-05-29 10:18 ` [PATCH v1 1/6] power: Drop unused assignment of platform_device_id driver data Uwe Kleine-König (The Capable Hub)
2026-05-29 22:02 ` Tzung-Bi Shih
2026-05-29 10:18 ` [PATCH v1 5/6] power: supply: mt6360_charger: Use of match table unconditionally Uwe Kleine-König (The Capable Hub)
2026-06-03 20:46 ` (subset) [PATCH v1 0/6] power: Use named initializers for platform_device_id arrays Sebastian Reichel
2026-06-26 8:20 ` patchwork-bot+linux-riscv
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox