mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] rtc: register RTC class to collect devices
Date: Mon,  1 Jul 2024 09:43:25 +0200	[thread overview]
Message-ID: <20240701074325.190376-1-a.fatoum@pengutronix.de> (raw)

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




             reply	other threads:[~2024-07-01  7:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-01  7:43 Ahmad Fatoum [this message]
2024-07-01  9:30 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240701074325.190376-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox