diff options
author | Alexandre Belloni <alexandre.belloni@bootlin.com> | 2021-04-18 02:20:23 +0200 |
---|---|---|
committer | Alexandre Belloni <alexandre.belloni@bootlin.com> | 2021-04-29 23:37:18 +0200 |
commit | a1cfe7cc3873baf83a26356cb5e10409c6fb942c (patch) | |
tree | 1cf6b54849f8623ac598e87675607093186816cd /drivers/rtc | |
parent | 13e37b7fb75dfaeb4f5a72468f0bd32853628d28 (diff) | |
download | linux-a1cfe7cc3873baf83a26356cb5e10409c6fb942c.tar.bz2 |
rtc: pcf8523: report oscillator failures
Report oscillator failures and invalid date/time on RTC_VL_READ.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20210418002023.1000265-3-alexandre.belloni@bootlin.com
Diffstat (limited to 'drivers/rtc')
-rw-r--r-- | drivers/rtc/rtc-pcf8523.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/rtc/rtc-pcf8523.c b/drivers/rtc/rtc-pcf8523.c index 4e5e5caeb8ce..740e2136ca98 100644 --- a/drivers/rtc/rtc-pcf8523.c +++ b/drivers/rtc/rtc-pcf8523.c @@ -406,6 +406,8 @@ static int pcf8523_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) { struct i2c_client *client = to_i2c_client(dev); + unsigned int flags = 0; + u8 value; int ret; switch (cmd) { @@ -414,9 +416,16 @@ static int pcf8523_rtc_ioctl(struct device *dev, unsigned int cmd, if (ret < 0) return ret; if (ret) - ret = RTC_VL_BACKUP_LOW; + flags |= RTC_VL_BACKUP_LOW; + + ret = pcf8523_read(client, REG_SECONDS, &value); + if (ret < 0) + return ret; + + if (value & REG_SECONDS_OS) + flags |= RTC_VL_DATA_INVALID; - return put_user(ret, (unsigned int __user *)arg); + return put_user(flags, (unsigned int __user *)arg); default: return -ENOIOCTLCMD; |