diff options
author | Alexandre Belloni <alexandre.belloni@bootlin.com> | 2019-12-14 23:02:57 +0100 |
---|---|---|
committer | Alexandre Belloni <alexandre.belloni@bootlin.com> | 2019-12-18 10:37:42 +0100 |
commit | bcd17c5082f2feef4b585ae37a471f61f7b0c2f6 (patch) | |
tree | 9f361543651f2a24bd5e5203354333f8cc8edf26 /drivers/rtc/rtc-rv8803.c | |
parent | 7e890a0f0e4d777d8292539a0609d3aeef6e6da4 (diff) | |
download | linux-bcd17c5082f2feef4b585ae37a471f61f7b0c2f6.tar.gz linux-bcd17c5082f2feef4b585ae37a471f61f7b0c2f6.tar.bz2 linux-bcd17c5082f2feef4b585ae37a471f61f7b0c2f6.zip |
rtc: rv8803: return meaningful value for RTC_VL_READ
RV8803_FLAG_V1F means the voltage is too low to keep the temperature
compensation running and the accuracy of the RTC is affected.
RV8803_FLAG_V2F means the voltage dropped so low that data is now invalid.
Link: https://lore.kernel.org/r/20191214220259.621996-16-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Diffstat (limited to 'drivers/rtc/rtc-rv8803.c')
-rw-r--r-- | drivers/rtc/rtc-rv8803.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/drivers/rtc/rtc-rv8803.c b/drivers/rtc/rtc-rv8803.c index ed92116bdfa0..93c3a6b627bd 100644 --- a/drivers/rtc/rtc-rv8803.c +++ b/drivers/rtc/rtc-rv8803.c @@ -411,6 +411,7 @@ static int rv8803_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) { struct i2c_client *client = to_i2c_client(dev); struct rv8803_data *rv8803 = dev_get_drvdata(dev); + unsigned int vl = 0; int flags, ret = 0; switch (cmd) { @@ -419,18 +420,15 @@ static int rv8803_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) if (flags < 0) return flags; - if (flags & RV8803_FLAG_V1F) + if (flags & RV8803_FLAG_V1F) { dev_warn(&client->dev, "Voltage low, temperature compensation stopped.\n"); + vl = RTC_VL_ACCURACY_LOW; + } if (flags & RV8803_FLAG_V2F) - dev_warn(&client->dev, "Voltage low, data loss detected.\n"); - - flags &= RV8803_FLAG_V1F | RV8803_FLAG_V2F; + vl |= RTC_VL_DATA_INVALID; - if (copy_to_user((void __user *)arg, &flags, sizeof(int))) - return -EFAULT; - - return 0; + return put_user(vl, (unsigned int __user *)arg); case RTC_VL_CLR: mutex_lock(&rv8803->flags_lock); |