power: Use named initializers for platform_device_id arrays
Subsystems (17)
cover power: Use named initializers for platform_device_id arrays
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
Signature · 1 line
2.47.3
PATCH 1/6 power: Drop unused assignment of platform_device_id driver data
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.
--- 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(-)
drivers/power/reset/qemu-virt-ctrl.c +1 -1
@@ -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);
drivers/power/supply/charger-manager.c +2 -2
@@ -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);
drivers/power/supply/cros_charge-control.c +2 -2
@@ -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 = {
drivers/power/supply/cros_peripheral_charger.c +2 -2
@@ -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);
drivers/power/supply/cros_usbpd-charger.c +2 -2
@@ -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);
drivers/power/supply/max77693_charger.c +1 -1
@@ -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);
drivers/power/supply/max8997_charger.c +1 -1
@@ -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);
drivers/power/supply/mt6360_charger.c +2 -2
@@ -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);
Signature · 1 line
2.47.3
Re: [PATCH v1 1/6] power: Drop unused assignment of platform_device_id driver data
Quoted 8 lines · Uwe Kleine-König (The Capable Hub)
The driver explicitly set the .driver_data member of struct
platform_device_idto 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) <[email protected]>
PATCH 2/6 power: supply: max14577: Drop driver data in of and platform device id arrays
In reply to Uwe Kleine-König (The Capable Hub)These values are not used, the relevant distinction happens in the mfd parent driver. So they can be dropped.
--- drivers/power/supply/max14577_charger.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/power/supply/max14577_charger.c +5 -7
@@ -613,18 +613,16 @@ static void max14577_charger_remove(struct platform_device *pdev) }static const struct platform_device_id max14577_charger_id[] = { - {"max14577-charger" ,MAXIM_DEVICE_TYPE_MAX14577 , }, - {"max77836-charger" ,MAXIM_DEVICE_TYPE_MAX77836 , }, + { .name ="max14577-charger" }, + { .name ="max77836-charger" }, { } };MODULE_DEVICE_TABLE (platform, max14577_charger_id);static const struct of_device_id of_max14577_charger_dt_match[] = { - { .compatible ="maxim,max14577-charger" , - .data = (void *)MAXIM_DEVICE_TYPE_MAX14577 , }, - { .compatible ="maxim,max77836-charger" , - .data = (void *)MAXIM_DEVICE_TYPE_MAX77836 , }, - { }, + { .compatible ="maxim,max14577-charger" }, + { .compatible ="maxim,max77836-charger" }, + { } };MODULE_DEVICE_TABLE (of, of_max14577_charger_dt_match);
Signature · 1 line
2.47.3
Re: [PATCH v1 2/6] power: supply: max14577: Drop driver data in of and platform device id arrays
Quoted 6 lines · Uwe Kleine-König (The Capable Hub)
These values are not used, the relevant distinction happens in the mfd parent driver. So they can be dropped.
Signed-off-by Uwe Kleine-König (The Capable Hub) <[email protected]>--- drivers/power/supply/max14577_charger.c | 12 +++++-------
Best regards,
Krzysztof
PATCH 3/6 power: supply: max17042: Drop driver data in of and platform device id arrays
In reply to Uwe Kleine-König (The Capable Hub)These values are not used, the relevant distinction happens in the mfd parent driver. So they can be dropped.
--- drivers/power/supply/max17042_battery.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/power/supply/max17042_battery.c +7 -7
@@ -1298,7 +1298,7 @@ static SIMPLE_DEV_PM_OPS(max17042_pm_ops, max17042_suspend,#ifdef CONFIG_ACPI static const struct acpi_device_id max17042_acpi_match[] = { - {"MAX17047" ,MAXIM_DEVICE_TYPE_MAX17047 }, + {"MAX17047" }, { } };MODULE_DEVICE_TABLE (acpi, max17042_acpi_match);
@@ -1346,12 +1346,12 @@ static const struct i2c_device_id max17042_id[] = {MODULE_DEVICE_TABLE (i2c, max17042_id);static const struct platform_device_id max17042_platform_id[] = { - {"max17042" ,MAXIM_DEVICE_TYPE_MAX17042 }, - {"max17047" ,MAXIM_DEVICE_TYPE_MAX17047 }, - {"max17050" ,MAXIM_DEVICE_TYPE_MAX17050 }, - {"max17055" ,MAXIM_DEVICE_TYPE_MAX17055 }, - {"max77705-battery" ,MAXIM_DEVICE_TYPE_MAX17047 }, - {"max77849-battery" ,MAXIM_DEVICE_TYPE_MAX17047 }, + { .name ="max17042" }, + { .name ="max17047" }, + { .name ="max17050" }, + { .name ="max17055" }, + { .name ="max77705-battery" }, + { .name ="max77849-battery" }, { } };MODULE_DEVICE_TABLE (platform, max17042_platform_id);
Signature · 1 line
2.47.3
Krzysztof Kozlowski
maintainerRe: [PATCH v1 3/6] power: supply: max17042: Drop driver data in of and platform device id arrays
Quoted 4 lines · Uwe Kleine-König (The Capable Hub)
These values are not used, the relevant distinction happens in the mfd parent driver. So they can be dropped.
Signed-off-by Uwe Kleine-König (The Capable Hub) <[email protected]>
I clearly see in this driver probe function 'chip_type = id->driver_data' which later is being used ('chip->chip_type = chip_type'), so I think it is used.
Best regards,
Krzysztof
Re: [PATCH v1 3/6] power: supply: max17042: Drop driver data in of and platform device id arrays
In reply to Uwe Kleine-König (The Capable Hub)Quoted 13 lines · Uwe Kleine-König (The Capable Hub)
These values are not used, the relevant distinction happens in the mfd parent driver. So they can be dropped.
Signed-off-by Uwe Kleine-König (The Capable Hub) <[email protected]>--- drivers/power/supply/max17042_battery.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/power/supply/max17042_battery.c +0
-0
drivers/power/supply/max17042_battery.c static SIMPLE_DEV_PM_OPS(max17042_pm_ops, max17042_suspend, · line 1301
Quoted 5 lines
drivers/power/supply/max17042_battery.c +1
-1@@ -1298,7 +1298,7 @@ static SIMPLE_DEV_PM_OPS(max17042_pm_ops, max17042_suspend,#ifdef CONFIG_ACPI static const struct acpi_device_id max17042_acpi_match[] = { - { "MAX17047", MAXIM_DEVICE_TYPE_MAX17047 }, + { "MAX17047" },
This part is wrong. I missed that max17042_acpi_match is also used for the i2c driver where the data is queried. Thanks to sashiko[1] for noticing.
So please don't apply this patch.
As of now I assume the other patches are fine. I will check which parts of the series didn't make it into next and/or the mainline later, probably around the next merge window and resend accordingly.
Thanks
Uwe
[1] https://sashiko.dev/#/patchset/cover.1780048925.git.u.kleine-koenig%40baylibre.com
PATCH 4/6 power: Use named initializers for platform_device_id arrays
In reply to Uwe Kleine-König (The Capable Hub)Named initializers are better readable and more robust to changes of the struct definition. This robustness is relevant for a planned change to struct platform_device_id replacing .driver_data by an anonymous union.
While touching these arrays unify spacing and usage of commas.
--- drivers/power/reset/spacemit-p1-reboot.c | 4 ++-- drivers/power/reset/tps65086-restart.c | 2 +- drivers/power/supply/bd71828-power.c | 8 ++++---- drivers/power/supply/macsmc-power.c | 2 +- drivers/power/supply/max77759_charger.c | 2 +- drivers/power/supply/max8998_charger.c | 2 +- drivers/power/supply/pf1550-charger.c | 2 +- drivers/power/supply/rt5033_charger.c | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-)
drivers/power/reset/spacemit-p1-reboot.c +2 -2
@@ -70,8 +70,8 @@ static int spacemit_p1_reboot_probe(struct platform_device *pdev) }static const struct platform_device_id spacemit_p1_reboot_id_table[] = { - {"spacemit-p1-reboot" , }, - {/* sentinel */ }, + { .name ="spacemit-p1-reboot" }, + {/* sentinel */ } };MODULE_DEVICE_TABLE (platform, spacemit_p1_reboot_id_table);
drivers/power/reset/tps65086-restart.c +1 -1
@@ -41,7 +41,7 @@ static int tps65086_restart_probe(struct platform_device *pdev) }static const struct platform_device_id tps65086_restart_id_table[] = { - {"tps65086-reset" , }, + { .name ="tps65086-reset" }, {/* sentinel */ } };MODULE_DEVICE_TABLE (platform, tps65086_restart_id_table);
drivers/power/supply/bd71828-power.c +4 -4
@@ -1184,10 +1184,10 @@ static int bd71828_power_probe(struct platform_device *pdev) }static const struct platform_device_id bd71828_charger_id[] = { - {"bd71815-power" ,ROHM_CHIP_TYPE_BD71815 }, - {"bd71828-power" ,ROHM_CHIP_TYPE_BD71828 }, - {"bd72720-power" ,ROHM_CHIP_TYPE_BD72720 }, - { }, + { .name ="bd71815-power" , .driver_data =ROHM_CHIP_TYPE_BD71815 }, + { .name ="bd71828-power" , .driver_data =ROHM_CHIP_TYPE_BD71828 }, + { .name ="bd72720-power" , .driver_data =ROHM_CHIP_TYPE_BD72720 }, + { } };MODULE_DEVICE_TABLE (platform, bd71828_charger_id);
drivers/power/supply/macsmc-power.c +1 -1
@@ -834,7 +834,7 @@ static void macsmc_power_remove(struct platform_device *pdev) }static const struct platform_device_id macsmc_power_id[] = { - {"macsmc-power" }, + { .name ="macsmc-power" }, {/* sentinel */ } };MODULE_DEVICE_TABLE (platform, macsmc_power_id);
drivers/power/supply/max77759_charger.c +1 -1
@@ -754,7 +754,7 @@ static int max77759_charger_probe(struct platform_device *pdev) }static const struct platform_device_id max77759_charger_id[] = { - { .name ="max77759-charger" , }, + { .name ="max77759-charger" }, { } };MODULE_DEVICE_TABLE (platform, max77759_charger_id);
drivers/power/supply/max8998_charger.c +1 -1
@@ -188,7 +188,7 @@ static int max8998_battery_probe(struct platform_device *pdev) }static const struct platform_device_id max8998_battery_id[] = { - {"max8998-battery" ,TYPE_MAX8998 }, + { .name ="max8998-battery" }, { } };MODULE_DEVICE_TABLE (platform, max8998_battery_id);
drivers/power/supply/pf1550-charger.c +1 -1
@@ -622,7 +622,7 @@ static int pf1550_charger_probe(struct platform_device *pdev) }static const struct platform_device_id pf1550_charger_id[] = { - {"pf1550-charger" , }, + { .name ="pf1550-charger" }, {/* sentinel */ } };MODULE_DEVICE_TABLE (platform, pf1550_charger_id);
drivers/power/supply/rt5033_charger.c +1 -1
@@ -727,7 +727,7 @@ static int rt5033_charger_probe(struct platform_device *pdev) }static const struct platform_device_id rt5033_charger_id[] = { - {"rt5033-charger" , }, + { .name ="rt5033-charger" }, { } };MODULE_DEVICE_TABLE (platform, rt5033_charger_id);
Signature · 1 line
2.47.3
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] The explicit `.driver_data` initialization `TYPE_MAX8998` for `max8998-battery` was silently…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The explicit .driver_data initialization TYPE_MAX8998 for max8998-battery was silently dropped without mention in the commit message. --
commit 02f2c38ebeef8dff34934050c70916818fb36a18
Author: Uwe Kleine-König (The Capable Hub) <[email protected]>
power: Use named initializers for platform_device_id arrays
This commit updates various power supply and reset drivers to use named initializers for platform_device_id arrays. It also unifies spacing and comma usage across these array definitions.
drivers/power/supply/max8998_charger.c static int max8998_battery_probe(struct platform_device *pdev) · line 191
Quoted 10 lines
drivers/power/supply/max8998_charger.c +1
-1@@ -188,7 +188,7 @@ static int max8998_battery_probe(struct platform_device *pdev) }static const struct platform_device_id max8998_battery_id[] = { - {"max8998-battery" ,TYPE_MAX8998 }, + { .name ="max8998-battery" },
[Severity: Low]
Is it intentional that the TYPE_MAX8998 driver data assignment was dropped here?
The explicit .driver_data initialization TYPE_MAX8998 for max8998-battery was silently dropped without mention in the commit message. While this has no functional impact as TYPE_MAX8998 evaluates to 0 and the driver data is entirely unused in max8998_battery_probe(), it constitutes a minor code and commit message mismatch.
Should this removal be documented in the commit message, or perhaps moved to an earlier patch in the series that drops unused assignments of platform_device_id driver data?
Quoted 3 lines
drivers/power/supply/max8998_charger.c +0
-0{ } };MODULE_DEVICE_TABLE (platform, max8998_battery_id);
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
Quoted 20 lines · On Fri, May 29, 2026 at 11:02:29AM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The explicit.driver_datainitializationTYPE_MAX8998formax8998-batterywas silently dropped without mention in the commit message. --commit
02f2c38ebeef8dff34934050c70916818fb36a18
Author: Uwe Kleine-König (The Capable Hub) <[email protected]>power: Use named initializers for
platform_device_idarraysThis commit updates various power supply and reset drivers to use named initializers for
platform_device_idarrays. It also unifies spacing and comma usage across these array definitions.Quoted 7 lines
drivers/power/supply/max8998_charger.c +0
-0@@ -188,7 +188,7 @@ static int max8998_battery_probe(struct platform_device *pdev) }
Quoted 7 lines
drivers/power/supply/max8998_charger.c static int max8998_battery_probe(struct platform_device *pdev) · line 191
Quoted 3 lines
drivers/power/supply/max8998_charger.c +1
-1static const struct platform_device_id max8998_battery_id[] = { - {"max8998-battery" ,TYPE_MAX8998 }, + { .name ="max8998-battery" },[Severity: Low]
Is it intentional that theTYPE_MAX8998driver data assignment was dropped here?
Yes, it was intentional, but that change doesn't fit to the commit log.
The driver doesn't use the value in .driver_data, so the change is fine in principle. Given that the patch was already applied, I think it's fine to keep it as is, but of course I'm open to respin with that detail fixed.
Best regards
Uwe
Quoted 17 lines · Uwe Kleine-König (The Capable Hub)
Named initializers are better readable and more robust to changes of the struct definition. This robustness is relevant for a planned change to struct
platform_device_idreplacing .driver_data by an anonymous union.While touching these arrays unify spacing and usage of commas.
Signed-off-by Uwe Kleine-König (The Capable Hub) <[email protected]>--- drivers/power/reset/spacemit-p1-reboot.c | 4 ++-- drivers/power/reset/tps65086-restart.c | 2 +- drivers/power/supply/bd71828-power.c | 8 ++++---- drivers/power/supply/macsmc-power.c | 2 +- drivers/power/supply/max77759_charger.c | 2 +- drivers/power/supply/max8998_charger.c | 2 +- drivers/power/supply/pf1550-charger.c | 2 +- drivers/power/supply/rt5033_charger.c | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-)
[snip]
drivers/power/supply/macsmc-power.c static void macsmc_power_remove(struct platform_device *pdev) · line 840
Quoted 13 lines
drivers/power/supply/macsmc-power.c +1
-1@@ -834,7 +834,7 @@ static void macsmc_power_remove(struct platform_device *pdev) }static const struct platform_device_id macsmc_power_id[] = { - {"macsmc-power" }, + { .name ="macsmc-power" }, {/* sentinel */ } };MODULE_DEVICE_TABLE (platform, macsmc_power_id);
For macsmc-power,
(I'm not sure if one can "Review-by" a specific section of a singular patch, but also the other changes in the patch look fine to me, so consider it reviewed as well.)
Hello Joshua,
Quoted 3 lines · Joshua Peisach
For macsmc-power,
Reviewed-by Joshua Peisach <[email protected]>
Thanks!
Quoted 3 lines
(I'm not sure if one can "Review-by" a specific section of a singular patch, but also the other changes in the patch look fine to me, so consider it reviewed as well.)
I think what you did is quite usual. The restriction doesn't make it into git history this way though. Another usual idiom that can be found often in git-log is:
Reviewed-by_ Joshua Peisach <[email protected]> # macsmc-power
(intentionally added did s/:/_/ to not make tools pick up this line).
Best regards
Uwe
Quoted 7 lines · Uwe Kleine-König (The Capable Hub)
Named initializers are better readable and more robust to changes of the struct definition. This robustness is relevant for a planned change to struct
platform_device_idreplacing .driver_data by an anonymous union.While touching these arrays unify spacing and usage of commas.
Signed-off-by Uwe Kleine-König (The Capable Hub) <[email protected]>
Yours,
-- Matti
Signature · 5 lines
Matti Vaittinen Linux kernel developer at ROHM Semiconductors Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~
PATCH 5/6 power: supply: mt6360_charger: Use of match table unconditionally
In reply to Uwe Kleine-König (The Capable Hub)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.
--- drivers/power/supply/mt6360_charger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/mt6360_charger.c +1 -1
@@ -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,
Signature · 1 line
2.47.3
PATCH 6/6 power: Unify code style for platform_device_id arrays
In reply to Uwe Kleine-König (The Capable Hub)Use a single space in the list terminator and remove the trailing comma.
--- drivers/power/supply/axp288_charger.c | 2 +- drivers/power/supply/axp288_fuel_gauge.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/power/supply/axp288_charger.c +1 -1
@@ -955,7 +955,7 @@ static int axp288_charger_probe(struct platform_device *pdev)static const struct platform_device_id axp288_charger_id_table[] = { { .name ="axp288_charger" }, - {}, + { } };MODULE_DEVICE_TABLE (platform, axp288_charger_id_table);
drivers/power/supply/axp288_fuel_gauge.c +1 -1
@@ -799,7 +799,7 @@ static int axp288_fuel_gauge_probe(struct platform_device *pdev)static const struct platform_device_id axp288_fg_id_table[] = { { .name =DEV_NAME }, - {}, + { } };MODULE_DEVICE_TABLE (platform, axp288_fg_id_table);
Signature · 1 line
2.47.3
Re: [PATCH v1 6/6] power: Unify code style for platform_device_id arrays
Quoted 4 lines · Uwe Kleine-König (The Capable Hub)
Use a single space in the list terminator and remove the trailing comma.
Signed-off-by Uwe Kleine-König (The Capable Hub) <[email protected]>
Sebastian Reichel
AppliedRe: (subset) [PATCH v1 0/6] power: Use named initializers for platform_device_id arrays
In reply to Uwe Kleine-König (The Capable Hub)Quoted 19 lines · Uwe Kleine-König (The Capable Hub)
this series targets to use named initializers for
platform_device_idarrays. 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; + }; };
Quoted 1 line
[...]
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: e3f669bed32287ae72c05a4ddab4a6687b0e62caBest regards,
Signature · 1 line
Sebastian Reichel <[email protected]>
This patch was applied to riscv/linux.git (fixes) by Sebastian Reichel <[email protected]>:
Hello:
This patch was applied to riscv/linux.git (fixes) by Sebastian Reichel <[email protected]>:
Quoted 9 lines · On Fri, 29 May 2026 12:18:15 +0200 you wrote:
Hello,
this series targets to use named initializers for
platform_device_idarrays. 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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html