Commit 6e6111f6 authored by Alexandre Belloni's avatar Alexandre Belloni

rtc: rx8581: error out when time invalid

Return an error when the date is unreliable because the battery is low.
Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
parent ed87c6d8
...@@ -109,6 +109,12 @@ static int rx8581_rtc_read_time(struct device *dev, struct rtc_time *tm) ...@@ -109,6 +109,12 @@ static int rx8581_rtc_read_time(struct device *dev, struct rtc_time *tm)
return -EIO; return -EIO;
} }
if (data & RX8581_FLAG_VLF) {
dev_warn(dev,
"low voltage detected, date/time is not reliable.\n");
return -EINVAL;
}
do { do {
/* If update flag set, clear it */ /* If update flag set, clear it */
if (data & RX8581_FLAG_UF) { if (data & RX8581_FLAG_UF) {
...@@ -136,10 +142,6 @@ static int rx8581_rtc_read_time(struct device *dev, struct rtc_time *tm) ...@@ -136,10 +142,6 @@ static int rx8581_rtc_read_time(struct device *dev, struct rtc_time *tm)
} }
} while (data & RX8581_FLAG_UF); } while (data & RX8581_FLAG_UF);
if (data & RX8581_FLAG_VLF)
dev_info(dev,
"low voltage detected, date/time is not reliable.\n");
dev_dbg(dev, "%s: raw data is sec=%02x, min=%02x, hr=%02x, " dev_dbg(dev, "%s: raw data is sec=%02x, min=%02x, hr=%02x, "
"wday=%02x, mday=%02x, mon=%02x, year=%02x\n", "wday=%02x, mday=%02x, mon=%02x, year=%02x\n",
__func__, __func__,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment