diff options
author | Alexandre Belloni <alexandre.belloni@bootlin.com> | 2019-12-14 23:02:51 +0100 |
---|---|---|
committer | Alexandre Belloni <alexandre.belloni@bootlin.com> | 2019-12-18 10:37:32 +0100 |
commit | b371b10e949a81693d5f3f327ebb86a81829045b (patch) | |
tree | b0c310644b151229e71452029866a51262757d09 /drivers/rtc | |
parent | 935272aade5ac17f6e6139968799421233c92c33 (diff) | |
download | linux-b371b10e949a81693d5f3f327ebb86a81829045b.tar.gz linux-b371b10e949a81693d5f3f327ebb86a81829045b.tar.bz2 linux-b371b10e949a81693d5f3f327ebb86a81829045b.zip |
rtc: pcf8563: return meaningful value for RTC_VL_READ
PCF8563_SC_LV means the voltage dropped too low and data has been lost.
Link: https://lore.kernel.org/r/20191214220259.621996-10-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Diffstat (limited to 'drivers/rtc')
-rw-r--r-- | drivers/rtc/rtc-pcf8563.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c index 7fc43950cf6c..b282c6b07969 100644 --- a/drivers/rtc/rtc-pcf8563.c +++ b/drivers/rtc/rtc-pcf8563.c @@ -277,20 +277,16 @@ static int pcf8563_rtc_set_time(struct device *dev, struct rtc_time *tm) static int pcf8563_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) { struct i2c_client *client = to_i2c_client(dev); - int vl, ret; + int ret; switch (cmd) { case RTC_VL_READ: - ret = i2c_smbus_read_byte_data(client, PCF8563_REG_SC); if (ret < 0) return ret; - vl = ret & PCF8563_SC_LV ? 1 : 0; - - if (copy_to_user((void __user *)arg, &vl, sizeof(int))) - return -EFAULT; - return 0; + return put_user(ret & PCF8563_SC_LV ? RTC_VL_DATA_INVALID : 0, + (unsigned int __user *)arg); default: return -ENOIOCTLCMD; } |