diff mbox series

[2/2] rtc: hym8563: Return -EINVAL if the time is known to be invalid

Message ID 20191212103658.937528-2-paul.kocialkowski@bootlin.com
State Superseded
Headers show
Series [1/2] rtc: hym8563: Read the valid flag directly instead of caching it | expand

Commit Message

Paul Kocialkowski Dec. 12, 2019, 10:36 a.m. UTC
The current code returns -EPERM when the voltage loss bit is set.
Since the bit indicates that the time value is not valid, return
-EINVAL instead, which is the appropriate error code for this
situation.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
 drivers/rtc/rtc-hym8563.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/rtc/rtc-hym8563.c b/drivers/rtc/rtc-hym8563.c
index 584a7815f246..e547a892b692 100644
--- a/drivers/rtc/rtc-hym8563.c
+++ b/drivers/rtc/rtc-hym8563.c
@@ -101,7 +101,7 @@  static int hym8563_rtc_read_time(struct device *dev, struct rtc_time *tm)
 	if (ret & HYM8563_SEC_VL) {
 		dev_warn(&client->dev,
 			 "no valid clock/calendar values available\n");
-		return -EPERM;
+		return -EINVAL;
 	}
 
 	tm->tm_sec = bcd2bin(buf[0] & HYM8563_SEC_MASK);