rtc: m41t80: set range
authorAlexandre Belloni <alexandre.belloni@bootlin.com>
Thu, 3 Oct 2019 21:35:44 +0000 (23:35 +0200)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Mon, 7 Oct 2019 13:49:16 +0000 (15:49 +0200)
This is a standard BCD RTC that will fail in 2100. The century bits don't
help because 2100 will be considered a leap year while it is not.

Link: https://lore.kernel.org/r/20191003213544.5359-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
drivers/rtc/rtc-m41t80.c

index 5f46f85f814b12d94c9e1cafc8ae9bc0b79e79cf..b813295a2eb5b8e222b75a31dfbda8736f944756 100644 (file)
@@ -235,9 +235,6 @@ static int m41t80_rtc_set_time(struct device *dev, struct rtc_time *tm)
        unsigned char buf[8];
        int err, flags;
 
-       if (tm->tm_year < 100 || tm->tm_year > 199)
-               return -EINVAL;
-
        buf[M41T80_REG_SSEC] = 0;
        buf[M41T80_REG_SEC] = bin2bcd(tm->tm_sec);
        buf[M41T80_REG_MIN] = bin2bcd(tm->tm_min);
@@ -925,6 +922,8 @@ static int m41t80_probe(struct i2c_client *client,
        }
 
        m41t80_data->rtc->ops = &m41t80_rtc_ops;
+       m41t80_data->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
+       m41t80_data->rtc->range_max = RTC_TIMESTAMP_END_2099;
 
        if (client->irq <= 0) {
                /* We cannot support UIE mode if we do not have an IRQ line */