* [PATCH v1 0/2] hwmon:
@ 2026-05-27 15:15 Uwe Kleine-König (The Capable Hub)
2026-05-27 15:15 ` [PATCH v1 1/2] hwmon: cros_ec: Drop unused assignment of platform_device_id driver data Uwe Kleine-König (The Capable Hub)
0 siblings, 1 reply; 4+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-05-27 15:15 UTC (permalink / raw)
To: Thomas Weißschuh, Guenter Roeck, Benson Leung
Cc: chrome-platform, linux-hwmon, linux-kernel
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. (There is no hwmon driver that benefits from this
change, so a driver from a different subsystem was used to show the
benefit.)
Best regards
Uwe
Uwe Kleine-König (The Capable Hub) (2):
hwmon: cros_ec: Drop unused assignment of platform_device_id driver
data
hwmon: Use named initializers for platform_device_id arrays
drivers/hwmon/cros_ec_hwmon.c | 4 ++--
drivers/hwmon/max197.c | 4 ++--
drivers/hwmon/ntc_thermistor.c | 24 ++++++++++++------------
drivers/hwmon/sht15.c | 10 +++++-----
4 files changed, 21 insertions(+), 21 deletions(-)
base-commit: e7e28506af98ce4e1059e5ec59334b335c00a246
--
2.47.3
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v1 1/2] hwmon: cros_ec: Drop unused assignment of platform_device_id driver data
2026-05-27 15:15 [PATCH v1 0/2] hwmon: Uwe Kleine-König (The Capable Hub)
@ 2026-05-27 15:15 ` Uwe Kleine-König (The Capable Hub)
2026-05-28 2:23 ` Tzung-Bi Shih
2026-05-29 5:37 ` Thomas Weißschuh
0 siblings, 2 replies; 4+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-05-27 15:15 UTC (permalink / raw)
To: Thomas Weißschuh, Guenter Roeck, Benson Leung
Cc: chrome-platform, linux-hwmon, linux-kernel
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 and use named initializers for
.name.
Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
---
drivers/hwmon/cros_ec_hwmon.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/cros_ec_hwmon.c b/drivers/hwmon/cros_ec_hwmon.c
index 7c308b0a4b9e..f6cf254395a8 100644
--- a/drivers/hwmon/cros_ec_hwmon.c
+++ b/drivers/hwmon/cros_ec_hwmon.c
@@ -654,8 +654,8 @@ static int cros_ec_hwmon_resume(struct platform_device *pdev)
}
static const struct platform_device_id cros_ec_hwmon_id[] = {
- { DRV_NAME, 0 },
- {}
+ { .name = DRV_NAME },
+ { }
};
MODULE_DEVICE_TABLE(platform, cros_ec_hwmon_id);
--
2.47.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v1 1/2] hwmon: cros_ec: Drop unused assignment of platform_device_id driver data
2026-05-27 15:15 ` [PATCH v1 1/2] hwmon: cros_ec: Drop unused assignment of platform_device_id driver data Uwe Kleine-König (The Capable Hub)
@ 2026-05-28 2:23 ` Tzung-Bi Shih
2026-05-29 5:37 ` Thomas Weißschuh
1 sibling, 0 replies; 4+ messages in thread
From: Tzung-Bi Shih @ 2026-05-28 2:23 UTC (permalink / raw)
To: Uwe Kleine-König (The Capable Hub)
Cc: Thomas Weißschuh, Guenter Roeck, Benson Leung,
chrome-platform, linux-hwmon, linux-kernel
On Wed, May 27, 2026 at 05:15:52PM +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 and use named initializers for
> .name.
>
> 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] 4+ messages in thread
* Re: [PATCH v1 1/2] hwmon: cros_ec: Drop unused assignment of platform_device_id driver data
2026-05-27 15:15 ` [PATCH v1 1/2] hwmon: cros_ec: Drop unused assignment of platform_device_id driver data Uwe Kleine-König (The Capable Hub)
2026-05-28 2:23 ` Tzung-Bi Shih
@ 2026-05-29 5:37 ` Thomas Weißschuh
1 sibling, 0 replies; 4+ messages in thread
From: Thomas Weißschuh @ 2026-05-29 5:37 UTC (permalink / raw)
To: Uwe Kleine-König (The Capable Hub)
Cc: Guenter Roeck, Benson Leung, chrome-platform, linux-hwmon,
linux-kernel
On 2026-05-27 17:15:52+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 and
> use named initializers for .name.
Not sure why this is better.
> Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
... but it doesn't really matter, so:
Acked-by: Thomas Weißschuh <linux@weissschuh.net>
> ---
> drivers/hwmon/cros_ec_hwmon.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hwmon/cros_ec_hwmon.c b/drivers/hwmon/cros_ec_hwmon.c
> index 7c308b0a4b9e..f6cf254395a8 100644
> --- a/drivers/hwmon/cros_ec_hwmon.c
> +++ b/drivers/hwmon/cros_ec_hwmon.c
> @@ -654,8 +654,8 @@ static int cros_ec_hwmon_resume(struct platform_device *pdev)
> }
>
> static const struct platform_device_id cros_ec_hwmon_id[] = {
> - { DRV_NAME, 0 },
> - {}
> + { .name = DRV_NAME },
> + { }
> };
> MODULE_DEVICE_TABLE(platform, cros_ec_hwmon_id);
>
> --
> 2.47.3
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-05-29 5:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-27 15:15 [PATCH v1 0/2] hwmon: Uwe Kleine-König (The Capable Hub)
2026-05-27 15:15 ` [PATCH v1 1/2] hwmon: cros_ec: Drop unused assignment of platform_device_id driver data Uwe Kleine-König (The Capable Hub)
2026-05-28 2:23 ` Tzung-Bi Shih
2026-05-29 5:37 ` Thomas Weißschuh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox