diff options
author | Jaehoon Chung <jh80.chung@samsung.com> | 2017-11-03 14:29:07 +0900 |
---|---|---|
committer | Jaehoon Chung <jh80.chung@samsung.com> | 2019-01-29 11:25:34 +0900 |
commit | e1de737ae529cb831cbe6a3127e2d33e97ca7240 (patch) | |
tree | 6725f54d478d8e8565a8b0743d30e050ef2f7272 | |
parent | 8ca3551825d75f8703dc18dc753c1623348745c0 (diff) | |
download | linux-artik7-e1de737ae529cb831cbe6a3127e2d33e97ca7240.tar.gz linux-artik7-e1de737ae529cb831cbe6a3127e2d33e97ca7240.tar.bz2 linux-artik7-e1de737ae529cb831cbe6a3127e2d33e97ca7240.zip |
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 <jh80.chung@samsung.com>
-rw-r--r-- | drivers/rtc/rtc-ds1307.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index 1f0ee024dbd9..eaf2c85e67c0 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, |