rtc: pcf85063: return meaningful value for RTC_VL_READ
authorAlexandre Belloni <alexandre.belloni@bootlin.com>
Sat, 14 Dec 2019 22:02:53 +0000 (23:02 +0100)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Wed, 18 Dec 2019 09:37:35 +0000 (10:37 +0100)
PCF85063_REG_SC_OS means the voltage dropped too low and data has been
lost.

Link: https://lore.kernel.org/r/20191214220259.621996-12-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
drivers/rtc/rtc-pcf85063.c

index 2ddd954..1db17ba 100644 (file)
@@ -289,15 +289,9 @@ static int pcf85063_ioctl(struct device *dev, unsigned int cmd,
                if (ret < 0)
                        return ret;
 
-               if (status & PCF85063_REG_SC_OS)
-                       dev_warn(&pcf85063->rtc->dev, "Voltage low, data loss detected.\n");
+               status = status & PCF85063_REG_SC_OS ? RTC_VL_DATA_INVALID : 0;
 
-               status &= PCF85063_REG_SC_OS;
-
-               if (copy_to_user((void __user *)arg, &status, sizeof(int)))
-                       return -EFAULT;
-
-               return 0;
+               return put_user(status, (unsigned int __user *)arg);
 
        default:
                return -ENOIOCTLCMD;