From e1de737ae529cb831cbe6a3127e2d33e97ca7240 Mon Sep 17 00:00:00 2001 From: Jaehoon Chung Date: Fri, 3 Nov 2017 14:29:07 +0900 Subject: [PATCH] rtc: ds1307: prevent to set the specific time value When using the time over "date 2038-01-19 03:14", Systemd is displaying the below log as spamming. "systemd[1]: Time has been changed" This patch is workaround for preventing to set the value over "2038-01-19". Refer to https://patchwork.kernel.org/patch/7133531/ Change-Id: Iab3823b63d738c0c63d4cee439ab53da335f4ef0 Signed-off-by: Jaehoon Chung --- drivers/rtc/rtc-ds1307.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index 1f0ee02..eaf2c85 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c @@ -392,6 +392,16 @@ static int ds1307_set_time(struct device *dev, struct rtc_time *t) int tmp; u8 *buf = ds1307->regs; + /* + * WORKAROUND: + * If try to set 2038/01/19, prevent to set the value. + */ + if (t->tm_year >= 138 && t->tm_mon > 0 && t->tm_mday > 18) { + dev_err(dev, "Can't set year = %d, mon = %d, mday = %d\n", + t->tm_year + 1900, t->tm_mon, t->tm_mday); + return -EINVAL; + } + dev_dbg(dev, "%s secs=%d, mins=%d, " "hours=%d, mday=%d, mon=%d, year=%d, wday=%d\n", "write", t->tm_sec, t->tm_min, -- 2.7.4