[PATCH 2/2] rtc: return first RTC when rtc_lookup(NULL) is called

Ahmad Fatoum a.fatoum at pengutronix.de
Tue Jul 16 05:03:30 PDT 2024


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 at 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




More information about the barebox mailing list