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 2/2] rtc: return first RTC when rtc_lookup(NULL) is called
Date: Tue, 16 Jul 2024 14:03:30 +0200	[thread overview]
Message-ID: <20240716120330.1988495-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20240716120330.1988495-1-a.fatoum@pengutronix.de>

We assume e.g. in hwclock, that we will have a rtc0 if we have any RTCs
at all. Instead of hardcoding specific names, let's just have
rtc_lookup(NULL) return the first best RTC.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/rtc/class.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c
index 3d6cfd6197a7..c09ec3f61ea2 100644
--- a/drivers/rtc/class.c
+++ b/drivers/rtc/class.c
@@ -18,11 +18,8 @@ struct rtc_device *rtc_lookup(const char *name)
 {
 	struct rtc_device *r;
 
-	if (!name)
-		return ERR_PTR(-ENODEV);
-
 	for_each_rtc(r) {
-		if (!strcmp(dev_name(&r->class_dev), name))
+		if (!name || !strcmp(dev_name(&r->class_dev), name))
 			return r;
 	}
 
-- 
2.39.2




  reply	other threads:[~2024-07-16 12:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-16 12:03 [PATCH 1/2] rtc: add stubs for when CONFIG_RTC_CLASS is disabled Ahmad Fatoum
2024-07-16 12:03 ` Ahmad Fatoum [this message]
2024-07-19  6:35 ` 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=20240716120330.1988495-2-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