]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
rtc: pcf8523: return meaningful value for RTC_VL_READ
authorAlexandre Belloni <alexandre.belloni@bootlin.com>
Sat, 14 Dec 2019 22:02:47 +0000 (23:02 +0100)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Wed, 18 Dec 2019 09:37:25 +0000 (10:37 +0100)
REG_CONTROL3_BLF indicates the battery is low and needs to be replaced
soon.

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

index b24c908f5f064ce916dba6a892d0a6f37c494203..47e0f411dd5cb744f84f0fa2269a882b9038e08c 100644 (file)
@@ -282,11 +282,11 @@ static int pcf8523_rtc_ioctl(struct device *dev, unsigned int cmd,
                ret = pcf8523_voltage_low(client);
                if (ret < 0)
                        return ret;
+               if (ret)
+                       ret = RTC_VL_BACKUP_LOW;
 
-               if (copy_to_user((void __user *)arg, &ret, sizeof(int)))
-                       return -EFAULT;
+               return put_user(ret, (unsigned int __user *)arg);
 
-               return 0;
        default:
                return -ENOIOCTLCMD;
        }