summaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-rx8581.c
diff options
context:
space:
mode:
authorAlexandre Belloni <alexandre.belloni@bootlin.com>2018-05-17 16:33:30 -0400
committerAlexandre Belloni <alexandre.belloni@bootlin.com>2018-05-17 16:43:22 -0400
commit6e6111f6c08dcc34c8bc3b3a2a4f944ceeaa78be (patch)
tree9309347eaa998fc7edb698d8c81ce14945a8b3e3 /drivers/rtc/rtc-rx8581.c
parented87c6d86d07dd345b2cd13f9be3794937165e04 (diff)
rtc: rx8581: error out when time invalid
Return an error when the date is unreliable because the battery is low. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Diffstat (limited to 'drivers/rtc/rtc-rx8581.c')
-rw-r--r--drivers/rtc/rtc-rx8581.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/rtc/rtc-rx8581.c b/drivers/rtc/rtc-rx8581.c
index 0a70f1ac5cc2..54631a3ab65f 100644
--- a/drivers/rtc/rtc-rx8581.c
+++ b/drivers/rtc/rtc-rx8581.c
@@ -109,6 +109,12 @@ static int rx8581_rtc_read_time(struct device *dev, struct rtc_time *tm)
109 return -EIO; 109 return -EIO;
110 } 110 }
111 111
112 if (data & RX8581_FLAG_VLF) {
113 dev_warn(dev,
114 "low voltage detected, date/time is not reliable.\n");
115 return -EINVAL;
116 }
117
112 do { 118 do {
113 /* If update flag set, clear it */ 119 /* If update flag set, clear it */
114 if (data & RX8581_FLAG_UF) { 120 if (data & RX8581_FLAG_UF) {
@@ -136,10 +142,6 @@ static int rx8581_rtc_read_time(struct device *dev, struct rtc_time *tm)
136 } 142 }
137 } while (data & RX8581_FLAG_UF); 143 } while (data & RX8581_FLAG_UF);
138 144
139 if (data & RX8581_FLAG_VLF)
140 dev_info(dev,
141 "low voltage detected, date/time is not reliable.\n");
142
143 dev_dbg(dev, "%s: raw data is sec=%02x, min=%02x, hr=%02x, " 145 dev_dbg(dev, "%s: raw data is sec=%02x, min=%02x, hr=%02x, "
144 "wday=%02x, mday=%02x, mon=%02x, year=%02x\n", 146 "wday=%02x, mday=%02x, mon=%02x, year=%02x\n",
145 __func__, 147 __func__,