aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc
diff options
context:
space:
mode:
authorJan Kardell <jan.kardell@telliq.com>2015-05-28 02:48:45 -0400
committerAlexandre Belloni <alexandre.belloni@free-electrons.com>2015-06-24 19:13:40 -0400
commit538330ccb93849530f5617d1fa870237496caa60 (patch)
tree5079ddae4de1e6ae2f5440c4a5e52efd1934fc3e /drivers/rtc
parent98a9bb5bf44bb6ee372f2a3b42703f597030cc48 (diff)
rtc: pcf8563 fix: return -EINVAL if we read an invalid time.
Return -EINVAL if the voltage low bit is set to avoid getting a bogus time at boot. There was a comment stating that util-linux hwclock refuses to set a new time if we return an error code on read, but at least the current version do set the time as expected. Remove the comment and the check for valid time, and let the rtc core check it for us. Signed-off-by: Jan Kardell <jan.kardell@telliq.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Diffstat (limited to 'drivers/rtc')
-rw-r--r--drivers/rtc/rtc-pcf8563.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
index 0ba7e59929be..229426dee1ea 100644
--- a/drivers/rtc/rtc-pcf8563.c
+++ b/drivers/rtc/rtc-pcf8563.c
@@ -22,7 +22,7 @@
22#include <linux/of.h> 22#include <linux/of.h>
23#include <linux/err.h> 23#include <linux/err.h>
24 24
25#define DRV_VERSION "0.4.3" 25#define DRV_VERSION "0.4.4"
26 26
27#define PCF8563_REG_ST1 0x00 /* status */ 27#define PCF8563_REG_ST1 0x00 /* status */
28#define PCF8563_REG_ST2 0x01 28#define PCF8563_REG_ST2 0x01
@@ -202,8 +202,9 @@ static int pcf8563_get_datetime(struct i2c_client *client, struct rtc_time *tm)
202 202
203 if (buf[PCF8563_REG_SC] & PCF8563_SC_LV) { 203 if (buf[PCF8563_REG_SC] & PCF8563_SC_LV) {
204 pcf8563->voltage_low = 1; 204 pcf8563->voltage_low = 1;
205 dev_info(&client->dev, 205 dev_err(&client->dev,
206 "low voltage detected, date/time is not reliable.\n"); 206 "low voltage detected, date/time is not reliable.\n");
207 return -EINVAL;
207 } 208 }
208 209
209 dev_dbg(&client->dev, 210 dev_dbg(&client->dev,
@@ -234,12 +235,6 @@ static int pcf8563_get_datetime(struct i2c_client *client, struct rtc_time *tm)
234 tm->tm_sec, tm->tm_min, tm->tm_hour, 235 tm->tm_sec, tm->tm_min, tm->tm_hour,
235 tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday); 236 tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday);
236 237
237 /* the clock can give out invalid datetime, but we cannot return
238 * -EINVAL otherwise hwclock will refuse to set the time on bootup.
239 */
240 if (rtc_valid_tm(tm) < 0)
241 dev_err(&client->dev, "retrieved date/time is not valid.\n");
242
243 return 0; 238 return 0;
244} 239}
245 240