rtc: ls1x: remove mktime usage
authorArnd Bergmann <arnd@arndb.de>
Fri, 20 Apr 2018 16:14:25 +0000 (18:14 +0200)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Thu, 3 May 2018 20:46:25 +0000 (22:46 +0200)
The loongson1 platform is 32-bit, so storing a time value in 32 bits
suffers from limited range. In this case it is likely to be correct
until 2106, but it's better to avoid the limitation and just use
the time64_t based mktime64() and rtc_time64_to_tm() interfaces.

The hardware uses a 32-bit year number, and time64_t can cover that
entire range.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
drivers/rtc/rtc-ls1x.c

index 045af1135e48a4049992ce7e8c176a116fb0f478..de86f9fabc1101f3c9febbf9ae665b6e7458b027 100644 (file)
 
 static int ls1x_rtc_read_time(struct device *dev, struct rtc_time *rtm)
 {
-       unsigned long v, t;
+       unsigned long v;
+       time64_t t;
 
        v = readl(SYS_TOYREAD0);
        t = readl(SYS_TOYREAD1);
 
        memset(rtm, 0, sizeof(struct rtc_time));
-       t  = mktime((t & LS1X_YEAR_MASK), ls1x_get_month(v),
+       t  = mktime64((t & LS1X_YEAR_MASK), ls1x_get_month(v),
                        ls1x_get_day(v), ls1x_get_hour(v),
                        ls1x_get_min(v), ls1x_get_sec(v));
-       rtc_time_to_tm(t, rtm);
+       rtc_time64_to_tm(t, rtm);
 
        return 0;
 }