* [PATCH v1 0/2] pinctrl: Use named initializers for platform_device_id arrays
@ 2026-05-27 15:42 Uwe Kleine-König (The Capable Hub)
2026-05-27 15:43 ` [PATCH v1 1/2] " Uwe Kleine-König (The Capable Hub)
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-05-27 15:42 UTC (permalink / raw)
To: Linus Walleij
Cc: David Rhodes, Richard Fitzgerald, Charles Keepax, Mika Westerberg,
Andy Shevchenko, Geert Uytterhoeven, linux-sound, patches,
linux-gpio, linux-kernel, linux-renesas-soc
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/pinctrl/renesas/core.c b/drivers/pinctrl/renesas/core.c
index a466ebf99593..5bb1c1205352 100644
--- a/drivers/pinctrl/renesas/core.c
+++ b/drivers/pinctrl/renesas/core.c
@@ -1313,7 +1313,7 @@ static int sh_pfc_probe(struct platform_device *pdev)
if (pdev->dev.of_node)
info = of_device_get_match_data(&pdev->dev);
else
- info = (const void *)platform_get_device_id(pdev)->driver_data;
+ info = platform_get_device_id(pdev)->driver_data_ptr;
pfc = devm_kzalloc(&pdev->dev, sizeof(*pfc), GFP_KERNEL);
if (pfc == NULL)
@@ -1380,40 +1380,40 @@ static int sh_pfc_probe(struct platform_device *pdev)
static const struct platform_device_id sh_pfc_id_table[] = {
#ifdef CONFIG_PINCTRL_PFC_SH7203
- { .name = "pfc-sh7203", .driver_data = (kernel_ulong_t)&sh7203_pinmux_info },
+ { .name = "pfc-sh7203", .driver_data_ptr = &sh7203_pinmux_info },
#endif
#ifdef CONFIG_PINCTRL_PFC_SH7264
- { .name = "pfc-sh7264", .driver_data = (kernel_ulong_t)&sh7264_pinmux_info },
+ { .name = "pfc-sh7264", .driver_data_ptr = &sh7264_pinmux_info },
#endif
#ifdef CONFIG_PINCTRL_PFC_SH7269
- { .name = "pfc-sh7269", .driver_data = (kernel_ulong_t)&sh7269_pinmux_info },
+ { .name = "pfc-sh7269", .driver_data_ptr = &sh7269_pinmux_info },
#endif
#ifdef CONFIG_PINCTRL_PFC_SH7720
- { .name = "pfc-sh7720", .driver_data = (kernel_ulong_t)&sh7720_pinmux_info },
+ { .name = "pfc-sh7720", .driver_data_ptr = &sh7720_pinmux_info },
#endif
#ifdef CONFIG_PINCTRL_PFC_SH7722
- { .name = "pfc-sh7722", .driver_data = (kernel_ulong_t)&sh7722_pinmux_info },
+ { .name = "pfc-sh7722", .driver_data_ptr = &sh7722_pinmux_info },
#endif
#ifdef CONFIG_PINCTRL_PFC_SH7723
- { .name = "pfc-sh7723", .driver_data = (kernel_ulong_t)&sh7723_pinmux_info },
+ { .name = "pfc-sh7723", .driver_data_ptr = &sh7723_pinmux_info },
#endif
#ifdef CONFIG_PINCTRL_PFC_SH7724
- { .name = "pfc-sh7724", .driver_data = (kernel_ulong_t)&sh7724_pinmux_info },
+ { .name = "pfc-sh7724", .driver_data_ptr = &sh7724_pinmux_info },
#endif
#ifdef CONFIG_PINCTRL_PFC_SH7734
- { .name = "pfc-sh7734", .driver_data = (kernel_ulong_t)&sh7734_pinmux_info },
+ { .name = "pfc-sh7734", .driver_data_ptr = &sh7734_pinmux_info },
#endif
#ifdef CONFIG_PINCTRL_PFC_SH7757
- { .name = "pfc-sh7757", .driver_data = (kernel_ulong_t)&sh7757_pinmux_info },
+ { .name = "pfc-sh7757", .driver_data_ptr = &sh7757_pinmux_info },
#endif
#ifdef CONFIG_PINCTRL_PFC_SH7785
- { .name = "pfc-sh7785", .driver_data = (kernel_ulong_t)&sh7785_pinmux_info },
+ { .name = "pfc-sh7785", .driver_data_ptr = &sh7785_pinmux_info },
#endif
#ifdef CONFIG_PINCTRL_PFC_SH7786
- { .name = "pfc-sh7786", .driver_data = (kernel_ulong_t)&sh7786_pinmux_info },
+ { .name = "pfc-sh7786", .driver_data_ptr = &sh7786_pinmux_info },
#endif
#ifdef CONFIG_PINCTRL_PFC_SHX3
- { .name = "pfc-shx3", .driver_data = (kernel_ulong_t)&shx3_pinmux_info },
+ { .name = "pfc-shx3", .driver_data_ptr = &shx3_pinmux_info },
#endif
{ /* sentinel */ }
};
increasing readability due to less casting which also improves type safety.
If you consider the 2nd patch mostly churn, just drop it.
Best regards
Uwe
Uwe Kleine-König (The Capable Hub) (2):
pinctrl: Use named initializers for platform_device_id arrays
pinctrl: max77620: Unify usage of space and comma in
platform_device_id array
drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 4 ++--
drivers/pinctrl/intel/pinctrl-broxton.c | 4 ++--
drivers/pinctrl/intel/pinctrl-denverton.c | 2 +-
drivers/pinctrl/pinctrl-max77620.c | 6 +++---
drivers/pinctrl/pinctrl-tps6594.c | 4 ++--
drivers/pinctrl/renesas/core.c | 24 +++++++++++------------
6 files changed, 22 insertions(+), 22 deletions(-)
base-commit: e7e28506af98ce4e1059e5ec59334b335c00a246
--
2.47.3
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v1 1/2] pinctrl: Use named initializers for platform_device_id arrays
2026-05-27 15:42 [PATCH v1 0/2] pinctrl: Use named initializers for platform_device_id arrays Uwe Kleine-König (The Capable Hub)
@ 2026-05-27 15:43 ` Uwe Kleine-König (The Capable Hub)
2026-05-27 15:51 ` Geert Uytterhoeven
2026-05-28 9:45 ` Mika Westerberg
2026-05-27 15:43 ` [PATCH v1 2/2] pinctrl: max77620: Unify usage of space and comma in platform_device_id array Uwe Kleine-König (The Capable Hub)
2026-05-29 20:48 ` [PATCH v1 0/2] pinctrl: Use named initializers for platform_device_id arrays Linus Walleij
2 siblings, 2 replies; 6+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-05-27 15:43 UTC (permalink / raw)
To: Linus Walleij
Cc: David Rhodes, Richard Fitzgerald, Charles Keepax, Mika Westerberg,
Andy Shevchenko, Geert Uytterhoeven, linux-sound, patches,
linux-gpio, linux-kernel, linux-renesas-soc
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 unit.
While touching these arrays unify spacing and usage of commas.
Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
---
drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 4 ++--
drivers/pinctrl/intel/pinctrl-broxton.c | 4 ++--
drivers/pinctrl/intel/pinctrl-denverton.c | 2 +-
drivers/pinctrl/pinctrl-tps6594.c | 4 ++--
drivers/pinctrl/renesas/core.c | 24 +++++++++++------------
5 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/drivers/pinctrl/cirrus/pinctrl-cs42l43.c b/drivers/pinctrl/cirrus/pinctrl-cs42l43.c
index 227c37c360e1..d9d3d1d3263d 100644
--- a/drivers/pinctrl/cirrus/pinctrl-cs42l43.c
+++ b/drivers/pinctrl/cirrus/pinctrl-cs42l43.c
@@ -604,8 +604,8 @@ static int cs42l43_pin_probe(struct platform_device *pdev)
}
static const struct platform_device_id cs42l43_pin_id_table[] = {
- { "cs42l43-pinctrl", },
- {}
+ { .name = "cs42l43-pinctrl" },
+ { }
};
MODULE_DEVICE_TABLE(platform, cs42l43_pin_id_table);
diff --git a/drivers/pinctrl/intel/pinctrl-broxton.c b/drivers/pinctrl/intel/pinctrl-broxton.c
index 3d3c1706928a..a33100f28488 100644
--- a/drivers/pinctrl/intel/pinctrl-broxton.c
+++ b/drivers/pinctrl/intel/pinctrl-broxton.c
@@ -995,8 +995,8 @@ static const struct acpi_device_id bxt_pinctrl_acpi_match[] = {
MODULE_DEVICE_TABLE(acpi, bxt_pinctrl_acpi_match);
static const struct platform_device_id bxt_pinctrl_platform_ids[] = {
- { "apollolake-pinctrl", (kernel_ulong_t)apl_pinctrl_soc_data },
- { "broxton-pinctrl", (kernel_ulong_t)bxt_pinctrl_soc_data },
+ { .name = "apollolake-pinctrl", .driver_data = (kernel_ulong_t)apl_pinctrl_soc_data },
+ { .name = "broxton-pinctrl", .driver_data = (kernel_ulong_t)bxt_pinctrl_soc_data },
{ }
};
MODULE_DEVICE_TABLE(platform, bxt_pinctrl_platform_ids);
diff --git a/drivers/pinctrl/intel/pinctrl-denverton.c b/drivers/pinctrl/intel/pinctrl-denverton.c
index 4a1d346fb30c..09aee90dee82 100644
--- a/drivers/pinctrl/intel/pinctrl-denverton.c
+++ b/drivers/pinctrl/intel/pinctrl-denverton.c
@@ -250,7 +250,7 @@ static const struct acpi_device_id dnv_pinctrl_acpi_match[] = {
MODULE_DEVICE_TABLE(acpi, dnv_pinctrl_acpi_match);
static const struct platform_device_id dnv_pinctrl_platform_ids[] = {
- { "denverton-pinctrl", (kernel_ulong_t)&dnv_soc_data },
+ { .name = "denverton-pinctrl", .driver_data = (kernel_ulong_t)&dnv_soc_data },
{ }
};
MODULE_DEVICE_TABLE(platform, dnv_pinctrl_platform_ids);
diff --git a/drivers/pinctrl/pinctrl-tps6594.c b/drivers/pinctrl/pinctrl-tps6594.c
index 6726853110d1..55dfa843e35e 100644
--- a/drivers/pinctrl/pinctrl-tps6594.c
+++ b/drivers/pinctrl/pinctrl-tps6594.c
@@ -562,8 +562,8 @@ static int tps6594_pinctrl_probe(struct platform_device *pdev)
}
static const struct platform_device_id tps6594_pinctrl_id_table[] = {
- { "tps6594-pinctrl", },
- {}
+ { .name = "tps6594-pinctrl" },
+ { }
};
MODULE_DEVICE_TABLE(platform, tps6594_pinctrl_id_table);
diff --git a/drivers/pinctrl/renesas/core.c b/drivers/pinctrl/renesas/core.c
index 0840668638d9..a466ebf99593 100644
--- a/drivers/pinctrl/renesas/core.c
+++ b/drivers/pinctrl/renesas/core.c
@@ -1380,40 +1380,40 @@ static int sh_pfc_probe(struct platform_device *pdev)
static const struct platform_device_id sh_pfc_id_table[] = {
#ifdef CONFIG_PINCTRL_PFC_SH7203
- { "pfc-sh7203", (kernel_ulong_t)&sh7203_pinmux_info },
+ { .name = "pfc-sh7203", .driver_data = (kernel_ulong_t)&sh7203_pinmux_info },
#endif
#ifdef CONFIG_PINCTRL_PFC_SH7264
- { "pfc-sh7264", (kernel_ulong_t)&sh7264_pinmux_info },
+ { .name = "pfc-sh7264", .driver_data = (kernel_ulong_t)&sh7264_pinmux_info },
#endif
#ifdef CONFIG_PINCTRL_PFC_SH7269
- { "pfc-sh7269", (kernel_ulong_t)&sh7269_pinmux_info },
+ { .name = "pfc-sh7269", .driver_data = (kernel_ulong_t)&sh7269_pinmux_info },
#endif
#ifdef CONFIG_PINCTRL_PFC_SH7720
- { "pfc-sh7720", (kernel_ulong_t)&sh7720_pinmux_info },
+ { .name = "pfc-sh7720", .driver_data = (kernel_ulong_t)&sh7720_pinmux_info },
#endif
#ifdef CONFIG_PINCTRL_PFC_SH7722
- { "pfc-sh7722", (kernel_ulong_t)&sh7722_pinmux_info },
+ { .name = "pfc-sh7722", .driver_data = (kernel_ulong_t)&sh7722_pinmux_info },
#endif
#ifdef CONFIG_PINCTRL_PFC_SH7723
- { "pfc-sh7723", (kernel_ulong_t)&sh7723_pinmux_info },
+ { .name = "pfc-sh7723", .driver_data = (kernel_ulong_t)&sh7723_pinmux_info },
#endif
#ifdef CONFIG_PINCTRL_PFC_SH7724
- { "pfc-sh7724", (kernel_ulong_t)&sh7724_pinmux_info },
+ { .name = "pfc-sh7724", .driver_data = (kernel_ulong_t)&sh7724_pinmux_info },
#endif
#ifdef CONFIG_PINCTRL_PFC_SH7734
- { "pfc-sh7734", (kernel_ulong_t)&sh7734_pinmux_info },
+ { .name = "pfc-sh7734", .driver_data = (kernel_ulong_t)&sh7734_pinmux_info },
#endif
#ifdef CONFIG_PINCTRL_PFC_SH7757
- { "pfc-sh7757", (kernel_ulong_t)&sh7757_pinmux_info },
+ { .name = "pfc-sh7757", .driver_data = (kernel_ulong_t)&sh7757_pinmux_info },
#endif
#ifdef CONFIG_PINCTRL_PFC_SH7785
- { "pfc-sh7785", (kernel_ulong_t)&sh7785_pinmux_info },
+ { .name = "pfc-sh7785", .driver_data = (kernel_ulong_t)&sh7785_pinmux_info },
#endif
#ifdef CONFIG_PINCTRL_PFC_SH7786
- { "pfc-sh7786", (kernel_ulong_t)&sh7786_pinmux_info },
+ { .name = "pfc-sh7786", .driver_data = (kernel_ulong_t)&sh7786_pinmux_info },
#endif
#ifdef CONFIG_PINCTRL_PFC_SHX3
- { "pfc-shx3", (kernel_ulong_t)&shx3_pinmux_info },
+ { .name = "pfc-shx3", .driver_data = (kernel_ulong_t)&shx3_pinmux_info },
#endif
{ /* sentinel */ }
};
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v1 2/2] pinctrl: max77620: Unify usage of space and comma in platform_device_id array
2026-05-27 15:42 [PATCH v1 0/2] pinctrl: Use named initializers for platform_device_id arrays Uwe Kleine-König (The Capable Hub)
2026-05-27 15:43 ` [PATCH v1 1/2] " Uwe Kleine-König (The Capable Hub)
@ 2026-05-27 15:43 ` Uwe Kleine-König (The Capable Hub)
2026-05-29 20:48 ` [PATCH v1 0/2] pinctrl: Use named initializers for platform_device_id arrays Linus Walleij
2 siblings, 0 replies; 6+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-05-27 15:43 UTC (permalink / raw)
To: Linus Walleij; +Cc: linux-gpio, linux-kernel
The most accepted style for the array terminator is to use a single
space between the curly braces and no trailing comma. Also don't use a comma
directly before a closing brace in the other entries.
Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
---
drivers/pinctrl/pinctrl-max77620.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-max77620.c b/drivers/pinctrl/pinctrl-max77620.c
index acb945a25743..c47eccce7dc0 100644
--- a/drivers/pinctrl/pinctrl-max77620.c
+++ b/drivers/pinctrl/pinctrl-max77620.c
@@ -645,9 +645,9 @@ static const struct dev_pm_ops max77620_pinctrl_pm_ops = {
};
static const struct platform_device_id max77620_pinctrl_devtype[] = {
- { .name = "max77620-pinctrl", },
- { .name = "max20024-pinctrl", },
- {},
+ { .name = "max77620-pinctrl" },
+ { .name = "max20024-pinctrl" },
+ { }
};
MODULE_DEVICE_TABLE(platform, max77620_pinctrl_devtype);
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/2] pinctrl: Use named initializers for platform_device_id arrays
2026-05-27 15:43 ` [PATCH v1 1/2] " Uwe Kleine-König (The Capable Hub)
@ 2026-05-27 15:51 ` Geert Uytterhoeven
2026-05-28 9:45 ` Mika Westerberg
1 sibling, 0 replies; 6+ messages in thread
From: Geert Uytterhoeven @ 2026-05-27 15:51 UTC (permalink / raw)
To: Uwe Kleine-König (The Capable Hub)
Cc: Linus Walleij, David Rhodes, Richard Fitzgerald, Charles Keepax,
Mika Westerberg, Andy Shevchenko, Geert Uytterhoeven, linux-sound,
patches, linux-gpio, linux-kernel, linux-renesas-soc
On Wed, 27 May 2026 at 17:43, Uwe Kleine-König (The Capable Hub)
<u.kleine-koenig@baylibre.com> wrote:
> 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 unit.
>
> While touching these arrays unify spacing and usage of commas.
>
> Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
> drivers/pinctrl/renesas/core.c | 24 +++++++++++------------
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> # renesas
Acked-by: Geert Uytterhoeven <geert+renesas@glider.be> # renesas
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/2] pinctrl: Use named initializers for platform_device_id arrays
2026-05-27 15:43 ` [PATCH v1 1/2] " Uwe Kleine-König (The Capable Hub)
2026-05-27 15:51 ` Geert Uytterhoeven
@ 2026-05-28 9:45 ` Mika Westerberg
1 sibling, 0 replies; 6+ messages in thread
From: Mika Westerberg @ 2026-05-28 9:45 UTC (permalink / raw)
To: Uwe Kleine-König (The Capable Hub)
Cc: Linus Walleij, David Rhodes, Richard Fitzgerald, Charles Keepax,
Andy Shevchenko, Geert Uytterhoeven, linux-sound, patches,
linux-gpio, linux-kernel, linux-renesas-soc
On Wed, May 27, 2026 at 05:43:00PM +0200, Uwe Kleine-König (The Capable Hub) wrote:
> 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 unit.
>
> While touching these arrays unify spacing and usage of commas.
>
> Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
> ---
> drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 4 ++--
> drivers/pinctrl/intel/pinctrl-broxton.c | 4 ++--
> drivers/pinctrl/intel/pinctrl-denverton.c | 2 +-
For Broxton and Denverton,
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 0/2] pinctrl: Use named initializers for platform_device_id arrays
2026-05-27 15:42 [PATCH v1 0/2] pinctrl: Use named initializers for platform_device_id arrays Uwe Kleine-König (The Capable Hub)
2026-05-27 15:43 ` [PATCH v1 1/2] " Uwe Kleine-König (The Capable Hub)
2026-05-27 15:43 ` [PATCH v1 2/2] pinctrl: max77620: Unify usage of space and comma in platform_device_id array Uwe Kleine-König (The Capable Hub)
@ 2026-05-29 20:48 ` Linus Walleij
2 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2026-05-29 20:48 UTC (permalink / raw)
To: Uwe Kleine-König (The Capable Hub)
Cc: David Rhodes, Richard Fitzgerald, Charles Keepax, Mika Westerberg,
Andy Shevchenko, Geert Uytterhoeven, linux-sound, patches,
linux-gpio, linux-kernel, linux-renesas-soc
On Wed, May 27, 2026 at 5:43 PM Uwe Kleine-König (The Capable Hub)
<u.kleine-koenig@baylibre.com> 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.
Patches applied!
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-05-29 20:48 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-27 15:42 [PATCH v1 0/2] pinctrl: Use named initializers for platform_device_id arrays Uwe Kleine-König (The Capable Hub)
2026-05-27 15:43 ` [PATCH v1 1/2] " Uwe Kleine-König (The Capable Hub)
2026-05-27 15:51 ` Geert Uytterhoeven
2026-05-28 9:45 ` Mika Westerberg
2026-05-27 15:43 ` [PATCH v1 2/2] pinctrl: max77620: Unify usage of space and comma in platform_device_id array Uwe Kleine-König (The Capable Hub)
2026-05-29 20:48 ` [PATCH v1 0/2] pinctrl: Use named initializers for platform_device_id arrays Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox