Skip to contentSkip to conversation

rtc: allow rtc_read_alarm without read_alarm callback

PATCH In review [email protected] 2 participants 2 messages Feb 14, 2023 – Feb 15, 2023 Real time clock (RTC)

lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/1 rtc: allow rtc_read_alarm without read_alarm callback

From: Alexandre Belloni <[email protected]>

.read_alarm is not necessary to read the current alarm because it is recorded in the aie_timer and so rtc_read_alarm() will never call rtc_read_alarm_internal() which is the only function calling the callback.

Fixes 7ae41220ef58 ("rtc: introduce features bitfield")
---
 drivers/rtc/interface.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/interface.c +1 -1
index 7c30cb3c764d..499d89150afc 100644
@@ -392,7 +392,7 @@ int rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
 		return err;
 	if (!rtc->ops) {
 		err = -ENODEV;
-	} else if (!test_bit(RTC_FEATURE_ALARM, rtc->features) || !rtc->ops->read_alarm) {
+	} else if (!test_bit(RTC_FEATURE_ALARM, rtc->features)) {
 		err = -EINVAL;
 	} else {
 		memset(alarm, 0, sizeof(struct rtc_wkalrm));
Signature · 1 line
2.39.1
Tested-by on v1 1/1
#1 lore raw
Quoted 11 lines · On Tue, 2023-02-14 at 23:27 +0100, [email protected] wrote:

From: Alexandre Belloni <[email protected]>

.read_alarm is not necessary to read the current alarm because it is recorded in the aie_timer and so rtc_read_alarm() will never call rtc_read_alarm_internal() which is the only function calling the callback.

Fixes 7ae41220ef58 ("rtc: introduce features bitfield")

I tested on our SoMs Colibri iMX8X and Apalis iMX8

I used the variants that had i.MX 8QXP and i.MX 8QM placed. This patch did solve the problem we currently have. I also wanted to mention that I could not get them to run on a mainline kernel in a acceptable time- frame so I tested on Toradex's kernel that is based on NXP's Kernel. [1]

[1]
https://git.toradex.com/cgit/linux-toradex.git/log/?h=toradex_5.15-2.1.x-imx

Quoted 19 lines

---
 drivers/rtc/interface.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/interface.c +1 -1
index 7c30cb3c764d..499d89150afc 100644
@@ -392,7 +392,7 @@ int rtc_read_alarm(struct rtc_device *rtc, struct
 rtc_wkalrm *alarm)
                 return err;
         if (!rtc->ops) {
                 err = -ENODEV;
-       } else if (!test_bit(RTC_FEATURE_ALARM, rtc->features) ||
 !rtc->ops->read_alarm) {
+       } else if (!test_bit(RTC_FEATURE_ALARM, rtc->features)) {
                 err = -EINVAL;

        } else {
                memset(alarm, 0, sizeof(struct rtc_wkalrm));