Skip to content

Commit 2b0386d

Browse files
groeckalexandrebelloni
authored andcommitted
rtc: rzn1: Report maximum alarm limit to rtc core
RZN1 only supports alarms up to one week in the future. Report the limit to the RTC core and use the reported limit to validate the requested alarm time when setting it. Cc: Brian Norris <[email protected]> Signed-off-by: Guenter Roeck <[email protected]> Reviewed-by: Miquel Raynal <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexandre Belloni <[email protected]>
1 parent 46b79ac commit 2b0386d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/rtc/rtc-rzn1.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ static int rzn1_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
227227
return ret;
228228

229229
/* We cannot set alarms more than one week ahead */
230-
farest = rtc_tm_to_time64(&tm_now) + (7 * 86400);
230+
farest = rtc_tm_to_time64(&tm_now) + rtc->rtcdev->alarm_offset_max;
231231
alarm = rtc_tm_to_time64(tm);
232232
if (time_after(alarm, farest))
233233
return -ERANGE;
@@ -351,6 +351,7 @@ static int rzn1_rtc_probe(struct platform_device *pdev)
351351

352352
rtc->rtcdev->range_min = RTC_TIMESTAMP_BEGIN_2000;
353353
rtc->rtcdev->range_max = RTC_TIMESTAMP_END_2099;
354+
rtc->rtcdev->alarm_offset_max = 7 * 86400;
354355
rtc->rtcdev->ops = &rzn1_rtc_ops;
355356
set_bit(RTC_FEATURE_ALARM_RES_MINUTE, rtc->rtcdev->features);
356357
clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, rtc->rtcdev->features);

0 commit comments

Comments
 (0)