Skip to contentSkip to conversation

alarmtimer: check RTC features instead of ops

PATCH Applied Alexandre Belloni 2 participants 2 messages May 11, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 alarmtimer: check RTC features instead of ops

RTC drivers used to leave .set_alarm() NULL in order to signal the RTC device doesn't support alarms. The drivers are now clearing the RTC_FEATURE_ALARM bit for that purpose in order to keep the rtc_class_ops structure const. So now, .set_alarm() is set unconditionally and this possibly causes the alarmtimer code to select an RTC device that doesn't support alarms.

Test RTC_FEATURE_ALARM instead of relying on ops->set_alarm to determine whether alarms are available.

Fixes 7ae41220ef58 ("rtc: introduce features bitfield")
---
 kernel/time/alarmtimer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/time/alarmtimer.c +1 -1
index bea9d08b1698..5897828b9d7e 100644
@@ -92,7 +92,7 @@ static int alarmtimer_rtc_add_device(struct device *dev,
 	if (rtcdev)
 		return -EBUSY;
 
-	if (!rtc->ops->set_alarm)
+	if (!test_bit(RTC_FEATURE_ALARM, rtc->features))
 		return -1;
 	if (!device_may_wakeup(rtc->dev.parent))
 		return -1;
Signature · 1 line
2.31.1
#1 lore raw

[tip: timers/urgent] alarmtimer: Check RTC features instead of ops

The following commit has been merged into the timers/urgent branch of tip:

The following commit has been merged into the timers/urgent branch of tip:

Commit-ID:     e09784a8a751e539dffc94d43bc917b0ac1e934a
Gitweb:        https://git.kernel.org/tip/e09784a8a751e539dffc94d43bc917b0ac1e934a
Author:        Alexandre Belloni <[email protected]>
AuthorDate:    Tue, 11 May 2021 03:45:16 +02:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Tue, 11 May 2021 21:28:04 +02:00

alarmtimer: Check RTC features instead of ops

RTC drivers used to leave .set_alarm() NULL in order to signal the RTC device doesn't support alarms. The drivers are now clearing the RTC_FEATURE_ALARM bit for that purpose in order to keep the rtc_class_ops structure const. So now, .set_alarm() is set unconditionally and this possibly causes the alarmtimer code to select an RTC device that doesn't support alarms.

Test RTC_FEATURE_ALARM instead of relying on ops->set_alarm to determine whether alarms are available.

---
 kernel/time/alarmtimer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/time/alarmtimer.c +1 -1
index bea9d08..5897828 100644
@@ -92,7 +92,7 @@ static int alarmtimer_rtc_add_device(struct device *dev,
 	if (rtcdev)
 		return -EBUSY;
 
-	if (!rtc->ops->set_alarm)
+	if (!test_bit(RTC_FEATURE_ALARM, rtc->features))
 		return -1;
 	if (!device_may_wakeup(rtc->dev.parent))
 		return -1;