Skip to content

Commit

Permalink
rtc: ls1x: add range
Browse files Browse the repository at this point in the history
While the year is encoded on 32 bits in SYS_TOYWRITE1i/SYS_TOYREAD1. The
Loongson 1c datasheet states that the range is from 0 to 99.

The current code exceeds this range and seems to be working, I deduce that
the leap year algorithm will fail in 2100.

Anyway, alarm registers only encode the year on 14 bits so with alarm
support, the range will always be limited to 0 to 16383.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
  • Loading branch information
Alexandre Belloni committed May 18, 2018
1 parent 14dc3ec commit d759924
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/rtc/rtc-ls1x.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ static int ls1x_rtc_probe(struct platform_device *pdev)

platform_set_drvdata(pdev, rtcdev);
rtcdev->ops = &ls1x_rtc_ops;
rtcdev->range_min = RTC_TIMESTAMP_BEGIN_1900;
rtcdev->range_max = RTC_TIMESTAMP_END_2099;

return rtc_register_device(rtcdev);
}
Expand Down

0 comments on commit d759924

Please sign in to comment.