]> Git Repo - linux.git/commitdiff
rtc: interface: Add RTC offset to alarm after fix-up
authorCsókás, Bence <[email protected]>
Wed, 19 Jun 2024 14:04:52 +0000 (16:04 +0200)
committerAlexandre Belloni <[email protected]>
Sat, 6 Jul 2024 22:40:17 +0000 (00:40 +0200)
`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: fd6792bb022e ("rtc: fix alarm read and set offset")
Signed-off-by: Csókás, Bence <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Alexandre Belloni <[email protected]>
drivers/rtc/interface.c

index 5faafb4aa55cc3c1bdc104df389e7ceb5f3063a3..cca650b2e0b94dfe77b13d4fd92447c8d695f9e2 100644 (file)
@@ -274,10 +274,9 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
                        return err;
 
                /* full-function RTCs won't have such missing fields */
-               if (rtc_valid_tm(&alarm->time) == 0) {
-                       rtc_add_offset(rtc, &alarm->time);
-                       return 0;
-               }
+               err = rtc_valid_tm(&alarm->time);
+               if (!err)
+                       goto done;
 
                /* get the "after" timestamp, to detect wrapped fields */
                err = rtc_read_time(rtc, &now);
@@ -379,6 +378,8 @@ done:
        if (err && alarm->enabled)
                dev_warn(&rtc->dev, "invalid alarm value: %ptR\n",
                         &alarm->time);
+       else
+               rtc_add_offset(rtc, &alarm->time);
 
        return err;
 }
This page took 0.051464 seconds and 4 git commands to generate.