Merge tag 'for-v4.6-rc/omap-fixes-a' of git://git.kernel.org/pub/scm/linux/kernel...
[deliverable/linux.git] / drivers / rtc / rtc-m41t80.c
index a82937e2f82405a0ecb1346bf667a5e6be2b8b2d..d107a8e72a7d21bbf47efd498d5b80b58613970b 100644 (file)
@@ -176,7 +176,13 @@ static int m41t80_set_datetime(struct i2c_client *client, struct rtc_time *tm)
                bin2bcd(tm->tm_mday) | (buf[M41T80_REG_DAY] & ~0x3f);
        buf[M41T80_REG_MON] =
                bin2bcd(tm->tm_mon + 1) | (buf[M41T80_REG_MON] & ~0x1f);
+
        /* assume 20YY not 19YY */
+       if (tm->tm_year < 100 || tm->tm_year > 199) {
+               dev_err(&client->dev, "Year must be between 2000 and 2099. It's %d.\n",
+                       tm->tm_year + 1900);
+               return -EINVAL;
+       }
        buf[M41T80_REG_YEAR] = bin2bcd(tm->tm_year % 100);
 
        if (i2c_transfer(client->adapter, msgs, 1) != 1) {
This page took 0.025406 seconds and 5 git commands to generate.