OSDN Git Service

rtc: hym8563: Return -EINVAL if the time is known to be invalid
[sagit-ice-cold/kernel_xiaomi_msm8998.git] / drivers / rtc / rtc-hym8563.c
index 097325d..dbec596 100644 (file)
@@ -105,7 +105,7 @@ static int hym8563_rtc_read_time(struct device *dev, struct rtc_time *tm)
 
        if (!hym8563->valid) {
                dev_warn(&client->dev, "no valid clock/calendar values available\n");
-               return -EPERM;
+               return -EINVAL;
        }
 
        ret = i2c_smbus_read_i2c_block_data(client, HYM8563_SEC, 7, buf);
@@ -144,7 +144,7 @@ static int hym8563_rtc_set_time(struct device *dev, struct rtc_time *tm)
         * it does not seem to carry it over a subsequent write/read.
         * So we'll limit ourself to 100 years, starting at 2000 for now.
         */
-       buf[6] = tm->tm_year - 100;
+       buf[6] = bin2bcd(tm->tm_year - 100);
 
        /*
         * CTL1 only contains TEST-mode bits apart from stop,