Skip to content

Commit 46b79ac

Browse files
groeckalexandrebelloni
authored andcommitted
rtc: ds1305: Report maximum alarm limit to rtc core
DS1305 only supports alarms up to 24 hours in the future. Report the limit to the RTC core, and use the reported limit to validate the requested alarm time when setting it. If the alarm is too large when trying to set an alarm, return -ERANGE instead of -EDOM to align with error codes returned by other rtc drivers. Cc: Brian Norris <[email protected]> Signed-off-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexandre Belloni <[email protected]>
1 parent 3637bbd commit 46b79ac

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/rtc/rtc-ds1305.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,8 @@ static int ds1305_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
336336
/* make sure alarm fires within the next 24 hours */
337337
if (later <= now)
338338
return -EINVAL;
339-
if ((later - now) > 24 * 60 * 60)
340-
return -EDOM;
339+
if ((later - now) > ds1305->rtc->alarm_offset_max)
340+
return -ERANGE;
341341

342342
/* disable alarm if needed */
343343
if (ds1305->ctrl[0] & DS1305_AEI0) {
@@ -691,6 +691,7 @@ static int ds1305_probe(struct spi_device *spi)
691691
ds1305->rtc->ops = &ds1305_ops;
692692
ds1305->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
693693
ds1305->rtc->range_max = RTC_TIMESTAMP_END_2099;
694+
ds1305->rtc->alarm_offset_max = 24 * 60 * 60;
694695

695696
ds1305_nvmem_cfg.priv = ds1305;
696697
status = devm_rtc_register_device(ds1305->rtc);

0 commit comments

Comments
 (0)