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

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

index ba5baaca47becf7586069419f2aecdc5b0f08905..4e50d6768f13bc798b24ee0d36558d40a993d53e 100644 (file)
@@ -199,11 +199,9 @@ static int pcf2127_rtc_ioctl(struct device *dev,
                if (ret)
                        return ret;
 
-               touser = touser & PCF2127_BIT_CTRL3_BLF ? 1 : 0;
+               touser = touser & PCF2127_BIT_CTRL3_BLF ? RTC_VL_BACKUP_LOW : 0;
 
-               if (copy_to_user((void __user *)arg, &touser, sizeof(int)))
-                       return -EFAULT;
-               return 0;
+               return put_user(touser, (unsigned int __user *)arg);
        default:
                return -ENOIOCTLCMD;
        }