Commit 463927a8 authored by Csókás, Bence's avatar Csókás, Bence Committed by Alexandre Belloni

rtc: interface: Add RTC offset to alarm after fix-up

`rtc_add_offset()` is called by `__rtc_read_time()`
and `__rtc_read_alarm()` to add the RTC's offset to
the raw read-outs from the device drivers. However,
in the latter case, a fix-up algorithm is run if
the RTC device does not report a full `struct rtc_time`
alarm value. In that case, the offset was forgot to be
added.

Fixes: fd6792bb ("rtc: fix alarm read and set offset")
Signed-off-by: default avatarCsókás, Bence <csokas.bence@prolan.hu>
Link: https://lore.kernel.org/r/20240619140451.2800578-1-csokas.bence@prolan.huSigned-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
parent 68f78c72
...@@ -274,10 +274,9 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) ...@@ -274,10 +274,9 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
return err; return err;
/* full-function RTCs won't have such missing fields */ /* full-function RTCs won't have such missing fields */
if (rtc_valid_tm(&alarm->time) == 0) { err = rtc_valid_tm(&alarm->time);
rtc_add_offset(rtc, &alarm->time); if (!err)
return 0; goto done;
}
/* get the "after" timestamp, to detect wrapped fields */ /* get the "after" timestamp, to detect wrapped fields */
err = rtc_read_time(rtc, &now); err = rtc_read_time(rtc, &now);
...@@ -379,6 +378,8 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) ...@@ -379,6 +378,8 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
if (err && alarm->enabled) if (err && alarm->enabled)
dev_warn(&rtc->dev, "invalid alarm value: %ptR\n", dev_warn(&rtc->dev, "invalid alarm value: %ptR\n",
&alarm->time); &alarm->time);
else
rtc_add_offset(rtc, &alarm->time);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment