Skip to content

Commit 2546e70

Browse files
groeckalexandrebelloni
authored andcommitted
rtc: cmos: Report supported alarm limit to rtc infrastructure
The alarm window supported by the cmos RTC depends on the chip and its configuration. Report the limit to the RTC core. 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 00c3092 commit 2546e70

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

drivers/rtc/rtc-cmos.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,10 @@ static inline void cmos_check_acpi_rtc_status(struct device *dev,
913913
#define INITSECTION __init
914914
#endif
915915

916+
#define SECS_PER_DAY (24 * 60 * 60)
917+
#define SECS_PER_MONTH (28 * SECS_PER_DAY)
918+
#define SECS_PER_YEAR (365 * SECS_PER_DAY)
919+
916920
static int INITSECTION
917921
cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
918922
{
@@ -1019,6 +1023,13 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
10191023
goto cleanup0;
10201024
}
10211025

1026+
if (cmos_rtc.mon_alrm)
1027+
cmos_rtc.rtc->alarm_offset_max = SECS_PER_YEAR - 1;
1028+
else if (cmos_rtc.day_alrm)
1029+
cmos_rtc.rtc->alarm_offset_max = SECS_PER_MONTH - 1;
1030+
else
1031+
cmos_rtc.rtc->alarm_offset_max = SECS_PER_DAY - 1;
1032+
10221033
rename_region(ports, dev_name(&cmos_rtc.rtc->dev));
10231034

10241035
if (!mc146818_does_rtc_work()) {

0 commit comments

Comments
 (0)