Linux RTC
 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)
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ 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] 9+ messages in thread

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

Thread overview: 9+ 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
2026-05-28  6:48 ` [PATCH v1 2/3] rtc: ab8500: Simplify driver_data handling Uwe Kleine-König (The Capable Hub)
2026-05-28 13:22   ` Linus Walleij
2026-05-28  6:48 ` [PATCH v1 3/3] rtc: Use named initializers for platform_device_id arrays Uwe Kleine-König (The Capable Hub)
2026-05-28  8:40   ` Karel Balej
2026-05-28 13:21   ` Linus Walleij
2026-05-29  7:33   ` Matti Vaittinen

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