summaryrefslogtreecommitdiff
path: root/drivers/rtc/rtc-davinci.c
diff options
context:
space:
mode:
authorAlexandre Belloni <alexandre.belloni@bootlin.com>2020-03-06 00:50:21 +0300
committerAlexandre Belloni <alexandre.belloni@bootlin.com>2020-03-16 13:12:09 +0300
commitb6d8f589204802ec531a9de69abd8563f4640d30 (patch)
treeba9355aec1ed81ecd2b063546898c09292c75999 /drivers/rtc/rtc-davinci.c
parentdc924ce9a1848cf5c86c878f0df16c725788e8d3 (diff)
downloadlinux-b6d8f589204802ec531a9de69abd8563f4640d30.tar.xz
rtc: davinci: let the core handle rtc range
Let the core handle offsetting and windowing the RTC range. This rtc has hours, minutes, seconds and 16bit days. As the driver has the RTC epoch set to year 2000, this means that the end of the range is 2^16 days minus one second later. This is Sun Jun 6 23:59:59 UTC 2179. This is better than the currently set year 2099. Link: https://lore.kernel.org/r/20200305215022.32533-3-alexandre.belloni@bootlin.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Diffstat (limited to 'drivers/rtc/rtc-davinci.c')
-rw-r--r--drivers/rtc/rtc-davinci.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/drivers/rtc/rtc-davinci.c b/drivers/rtc/rtc-davinci.c
index 3043ffea8f7c..55d826dafe1d 100644
--- a/drivers/rtc/rtc-davinci.c
+++ b/drivers/rtc/rtc-davinci.c
@@ -258,10 +258,6 @@ static int convert2days(u16 *days, struct rtc_time *tm)
int i;
*days = 0;
- /* epoch == 1900 */
- if (tm->tm_year < 100 || tm->tm_year > 199)
- return -EINVAL;
-
for (i = 2000; i < 1900 + tm->tm_year; i++)
*days += rtc_year_days(1, 12, i);
@@ -313,8 +309,7 @@ static int davinci_rtc_set_time(struct device *dev, struct rtc_time *tm)
u8 rtc_cctrl;
unsigned long flags;
- if (convert2days(&days, tm) < 0)
- return -EINVAL;
+ convert2days(&days, tm);
spin_lock_irqsave(&davinci_rtc_lock, flags);
@@ -413,8 +408,7 @@ static int davinci_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
unsigned long flags;
u16 days;
- if (convert2days(&days, &alm->time) < 0)
- return -EINVAL;
+ convert2days(&days, &alm->time);
spin_lock_irqsave(&davinci_rtc_lock, flags);
@@ -469,6 +463,8 @@ static int __init davinci_rtc_probe(struct platform_device *pdev)
return PTR_ERR(davinci_rtc->rtc);
davinci_rtc->rtc->ops = &davinci_rtc_ops;
+ davinci_rtc->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
+ davinci_rtc->rtc->range_max = RTC_TIMESTAMP_BEGIN_2000 + (1 << 16) * 86400ULL - 1;
rtcif_write(davinci_rtc, PRTCIF_INTFLG_RTCSS, PRTCIF_INTFLG);
rtcif_write(davinci_rtc, 0, PRTCIF_INTEN);