aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/rtc/rtc-pcf8523.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/rtc/rtc-pcf8523.c b/drivers/rtc/rtc-pcf8523.c
index e7ebcc0b7e59..988566caaaa6 100644
--- a/drivers/rtc/rtc-pcf8523.c
+++ b/drivers/rtc/rtc-pcf8523.c
@@ -219,6 +219,17 @@ static int pcf8523_rtc_set_time(struct device *dev, struct rtc_time *tm)
219 u8 regs[8]; 219 u8 regs[8];
220 int err; 220 int err;
221 221
222 /*
223 * The hardware can only store values between 0 and 99 in it's YEAR
224 * register (with 99 overflowing to 0 on increment).
225 * After 2100-02-28 we could start interpreting the year to be in the
226 * interval [2100, 2199], but there is no path to switch in a smooth way
227 * because the chip handles YEAR=0x00 (and the out-of-spec
228 * YEAR=0xa0) as a leap year, but 2100 isn't.
229 */
230 if (tm->tm_year < 100 || tm->tm_year >= 200)
231 return -EINVAL;
232
222 err = pcf8523_stop_rtc(client); 233 err = pcf8523_stop_rtc(client);
223 if (err < 0) 234 if (err < 0)
224 return err; 235 return err;