rtc: abx80x: return meaningful value for RTC_VL_READ
authorAlexandre Belloni <alexandre.belloni@bootlin.com>
Sat, 14 Dec 2019 22:02:45 +0000 (23:02 +0100)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Wed, 18 Dec 2019 09:37:21 +0000 (10:37 +0100)
ABX8XX_STATUS_BLF indicates the battery is low and needs to be replaced
soon.

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

index 73830670a41f13b6eb4a5afe09b75f878f11e271..3521d8e8dc38da4054ecb2ad09e7b9ab58bce2f5 100644 (file)
@@ -523,12 +523,9 @@ static int abx80x_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
                if (status < 0)
                        return status;
 
-               tmp = !!(status & ABX8XX_STATUS_BLF);
+               tmp = status & ABX8XX_STATUS_BLF ? RTC_VL_BACKUP_LOW : 0;
 
-               if (copy_to_user((void __user *)arg, &tmp, sizeof(int)))
-                       return -EFAULT;
-
-               return 0;
+               return put_user(tmp, (unsigned int __user *)arg);
 
        case RTC_VL_CLR:
                status = i2c_smbus_read_byte_data(client, ABX8XX_REG_STATUS);