* [PATCH] rtc: register RTC class to collect devices
@ 2024-07-01 7:43 Ahmad Fatoum
2024-07-01 9:30 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2024-07-01 7:43 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
We already have an RTC class device, so by using struct class, we can
drop the list member in struct rtc_device and make it possible to list
the device using the class command.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/rtc/class.c | 10 ++++++----
include/linux/rtc.h | 1 -
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c
index 3edb294ed772..3d6cfd6197a7 100644
--- a/drivers/rtc/class.c
+++ b/drivers/rtc/class.c
@@ -8,9 +8,11 @@
#include <linux/err.h>
#include <rtc.h>
#include <linux/rtc.h>
+#include <device.h>
-LIST_HEAD(rtc_list);
-EXPORT_SYMBOL(rtc_list);
+#define for_each_rtc(rtc) list_for_each_entry(rtc, &rtc_class.devices, class_dev.class_list)
+
+DEFINE_DEV_CLASS(rtc_class, "rtc");
struct rtc_device *rtc_lookup(const char *name)
{
@@ -19,7 +21,7 @@ struct rtc_device *rtc_lookup(const char *name)
if (!name)
return ERR_PTR(-ENODEV);
- list_for_each_entry(r, &rtc_list, list) {
+ for_each_rtc(r) {
if (!strcmp(dev_name(&r->class_dev), name))
return r;
}
@@ -62,7 +64,7 @@ int rtc_register(struct rtc_device *rtcdev)
dev->parent = rtcdev->dev;
platform_device_register(dev);
- list_add_tail(&rtcdev->list, &rtc_list);
+ class_add_device(&rtc_class, &rtcdev->class_dev);
return 0;
}
diff --git a/include/linux/rtc.h b/include/linux/rtc.h
index def07548c554..82a82ce61682 100644
--- a/include/linux/rtc.h
+++ b/include/linux/rtc.h
@@ -26,7 +26,6 @@ struct rtc_class_ops;
struct rtc_device {
struct device *dev;
struct device class_dev;
- struct list_head list;
const struct rtc_class_ops *ops;
};
--
2.39.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] rtc: register RTC class to collect devices
2024-07-01 7:43 [PATCH] rtc: register RTC class to collect devices Ahmad Fatoum
@ 2024-07-01 9:30 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2024-07-01 9:30 UTC (permalink / raw)
To: barebox, Ahmad Fatoum
On Mon, 01 Jul 2024 09:43:25 +0200, Ahmad Fatoum wrote:
> We already have an RTC class device, so by using struct class, we can
> drop the list member in struct rtc_device and make it possible to list
> the device using the class command.
>
>
Applied, thanks!
[1/1] rtc: register RTC class to collect devices
https://git.pengutronix.de/cgit/barebox/commit/?id=fa13fd085f1a (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-07-01 9:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-01 7:43 [PATCH] rtc: register RTC class to collect devices Ahmad Fatoum
2024-07-01 9:30 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox