Chrome platform driver development
 help / color / mirror / Atom feed
* [PATCH v1 0/3] rtc: Use named initializers for platform_device_id arrays
@ 2026-05-28  6:48 Uwe Kleine-König (The Capable Hub)
  2026-05-28  6:48 ` [PATCH v1 1/3] rtc: Drop unused assignment of platform_device_id driver data Uwe Kleine-König (The Capable Hub)
  0 siblings, 1 reply; 3+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-05-28  6:48 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Benson Leung, Guenter Roeck, linux-rtc, chrome-platform,
	linux-kernel, Linus Walleij, linux-arm-kernel, Karel Balej,
	Matti Vaittinen, Chanwoo Choi, Krzysztof Kozlowski,
	André Draszik, linux-samsung-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/rtc/rtc-max77686.c b/drivers/rtc/rtc-max77686.c
	index 375565a3bddf..31b641bd8962 100644
	--- a/drivers/rtc/rtc-max77686.c
	+++ b/drivers/rtc/rtc-max77686.c
	@@ -760,8 +760,7 @@ static int max77686_rtc_probe(struct platform_device *pdev)
	 
		mutex_init(&info->lock);
		info->dev = &pdev->dev;
	-	info->drv_data = (const struct max77686_rtc_driver_data *)
	-		id->driver_data;
	+	info->drv_data = id->driver_data_ptr;
	 
		ret = max77686_init_rtc_regmap(info);
		if (ret < 0)
	@@ -866,10 +865,10 @@ static SIMPLE_DEV_PM_OPS(max77686_rtc_pm_ops,
				 max77686_rtc_suspend, max77686_rtc_resume);
	 
	 static const struct platform_device_id rtc_id[] = {
	-	{ .name = "max77686-rtc", .driver_data = (kernel_ulong_t)&max77686_drv_data },
	-	{ .name = "max77802-rtc", .driver_data = (kernel_ulong_t)&max77802_drv_data },
	-	{ .name = "max77620-rtc", .driver_data = (kernel_ulong_t)&max77620_drv_data },
	-	{ .name = "max77714-rtc", .driver_data = (kernel_ulong_t)&max77714_drv_data },
	+	{ .name = "max77686-rtc", .driver_data_ptr = &max77686_drv_data },
	+	{ .name = "max77802-rtc", .driver_data_ptr = &max77802_drv_data },
	+	{ .name = "max77620-rtc", .driver_data_ptr = &max77620_drv_data },
	+	{ .name = "max77714-rtc", .driver_data_ptr = &max77714_drv_data },
		{ }
	 };
	 MODULE_DEVICE_TABLE(platform, rtc_id);

increasing readability due to less casting which also improves type safety.

Best regards
Uwe

Uwe Kleine-König (The Capable Hub) (3):
  rtc: Drop unused assignment of platform_device_id driver data
  rtc: ab8500: Simplify driver_data handling
  rtc: Use named initializers for platform_device_id arrays

 drivers/rtc/rtc-88pm886.c  |  2 +-
 drivers/rtc/rtc-ab8500.c   |  5 ++---
 drivers/rtc/rtc-bd70528.c  |  8 ++++----
 drivers/rtc/rtc-cros-ec.c  |  4 ++--
 drivers/rtc/rtc-max77686.c | 10 +++++-----
 drivers/rtc/rtc-max8997.c  |  4 ++--
 drivers/rtc/rtc-max8998.c  |  4 ++--
 drivers/rtc/rtc-s5m.c      | 12 ++++++------
 drivers/rtc/rtc-tps6594.c  |  4 ++--
 9 files changed, 26 insertions(+), 27 deletions(-)


base-commit: e7d700e14934e68f86338c5610cf2ae76798b663
-- 
2.47.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v1 1/3] rtc: Drop unused assignment of platform_device_id driver data
  2026-05-28  6:48 [PATCH v1 0/3] rtc: Use named initializers for platform_device_id arrays Uwe Kleine-König (The Capable Hub)
@ 2026-05-28  6:48 ` Uwe Kleine-König (The Capable Hub)
  2026-05-28  7:43   ` Tzung-Bi Shih
  0 siblings, 1 reply; 3+ messages in thread
From: Uwe Kleine-König (The Capable Hub) @ 2026-05-28  6:48 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Benson Leung, Guenter Roeck, linux-rtc, chrome-platform,
	linux-kernel

The two drivers explicitly set the .driver_data member of struct
platform_device_id to zero without relying on that value. Drop this
unused assignments.

While touching these array unify spacing, usage of commas and use named
initializers for .name.

Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
---
 drivers/rtc/rtc-cros-ec.c | 4 ++--
 drivers/rtc/rtc-max8997.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/rtc/rtc-cros-ec.c b/drivers/rtc/rtc-cros-ec.c
index e956505a06fb..f3ecd017e2f7 100644
--- a/drivers/rtc/rtc-cros-ec.c
+++ b/drivers/rtc/rtc-cros-ec.c
@@ -388,8 +388,8 @@ static void cros_ec_rtc_remove(struct platform_device *pdev)
 }
 
 static const struct platform_device_id cros_ec_rtc_id[] = {
-	{ DRV_NAME, 0 },
-	{}
+	{ .name = DRV_NAME },
+	{ }
 };
 MODULE_DEVICE_TABLE(platform, cros_ec_rtc_id);
 
diff --git a/drivers/rtc/rtc-max8997.c b/drivers/rtc/rtc-max8997.c
index e7618d715bd8..89203c92e2cd 100644
--- a/drivers/rtc/rtc-max8997.c
+++ b/drivers/rtc/rtc-max8997.c
@@ -512,8 +512,8 @@ static void max8997_rtc_shutdown(struct platform_device *pdev)
 }
 
 static const struct platform_device_id rtc_id[] = {
-	{ "max8997-rtc", 0 },
-	{},
+	{ .name = "max8997-rtc" },
+	{ }
 };
 MODULE_DEVICE_TABLE(platform, rtc_id);
 
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1 1/3] rtc: Drop unused assignment of platform_device_id driver data
  2026-05-28  6:48 ` [PATCH v1 1/3] rtc: Drop unused assignment of platform_device_id driver data Uwe Kleine-König (The Capable Hub)
@ 2026-05-28  7:43   ` Tzung-Bi Shih
  0 siblings, 0 replies; 3+ messages in thread
From: Tzung-Bi Shih @ 2026-05-28  7:43 UTC (permalink / raw)
  To: Uwe Kleine-König (The Capable Hub)
  Cc: Alexandre Belloni, Benson Leung, Guenter Roeck, linux-rtc,
	chrome-platform, linux-kernel

On Thu, May 28, 2026 at 08:48:10AM +0200, Uwe Kleine-König (The Capable Hub) wrote:
> The two drivers explicitly set the .driver_data member of struct
> platform_device_id to zero without relying on that value. Drop this
> unused assignments.
> 
> While touching these array unify spacing, usage of commas 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] 3+ messages in thread

end of thread, other threads:[~2026-05-28  7:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-28  6:48 [PATCH v1 0/3] rtc: Use named initializers for platform_device_id arrays Uwe Kleine-König (The Capable Hub)
2026-05-28  6:48 ` [PATCH v1 1/3] rtc: Drop unused assignment of platform_device_id driver data Uwe Kleine-König (The Capable Hub)
2026-05-28  7:43   ` Tzung-Bi Shih

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox