* [PATCH resubmit] rtc: interface: Add RTC offset to alarm after fix-up
@ 2024-06-19 13:01 Csókás, Bence
2024-06-19 13:26 ` Alexandre Belloni
0 siblings, 1 reply; 2+ messages in thread
From: Csókás, Bence @ 2024-06-19 13:01 UTC (permalink / raw)
To: Alexandre Belloni, linux-rtc, linux-kernel; +Cc: Csókás, Bence
`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 <csokas.bence@prolan.hu>
---
drivers/rtc/interface.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index 1b63111cdda2..db8dffffed91 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -273,12 +273,11 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
if (err)
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;
+ goto done;
}
/* get the "after" timestamp, to detect wrapped fields */
err = rtc_read_time(rtc, &now);
if (err < 0)
@@ -378,10 +377,12 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
done:
if (err && alarm->enabled)
dev_warn(&rtc->dev, "invalid alarm value: %ptR\n",
&alarm->time);
+ rtc_add_offset(rtc, &alarm->time);
+
return err;
}
int rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
{
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH resubmit] rtc: interface: Add RTC offset to alarm after fix-up
2024-06-19 13:01 [PATCH resubmit] rtc: interface: Add RTC offset to alarm after fix-up Csókás, Bence
@ 2024-06-19 13:26 ` Alexandre Belloni
0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2024-06-19 13:26 UTC (permalink / raw)
To: Csókás, Bence; +Cc: linux-rtc, linux-kernel
On 19/06/2024 15:01:16+0200, Csókás, Bence wrote:
> `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 <csokas.bence@prolan.hu>
> ---
> drivers/rtc/interface.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
> index 1b63111cdda2..db8dffffed91 100644
> --- a/drivers/rtc/interface.c
> +++ b/drivers/rtc/interface.c
> @@ -273,12 +273,11 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
> if (err)
> 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;
> + goto done;
> }
>
> /* get the "after" timestamp, to detect wrapped fields */
> err = rtc_read_time(rtc, &now);
> if (err < 0)
> @@ -378,10 +377,12 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
> done:
> if (err && alarm->enabled)
> dev_warn(&rtc->dev, "invalid alarm value: %ptR\n",
> &alarm->time);
>
> + rtc_add_offset(rtc, &alarm->time);
> +
This must not be done when the tm is invalid.
> return err;
> }
>
> int rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
> {
> --
> 2.34.1
>
>
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-06-19 13:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-19 13:01 [PATCH resubmit] rtc: interface: Add RTC offset to alarm after fix-up Csókás, Bence
2024-06-19 13:26 ` Alexandre Belloni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).