summaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-m41t80.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc/rtc-m41t80.c')
-rw-r--r--drivers/rtc/rtc-m41t80.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index a3fb235fea0d..ebf50b1540f2 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -217,7 +217,7 @@ static int m41t80_rtc_read_time(struct device *dev, struct rtc_time *tm)
217 sizeof(buf), buf); 217 sizeof(buf), buf);
218 if (err < 0) { 218 if (err < 0) {
219 dev_err(&client->dev, "Unable to read date\n"); 219 dev_err(&client->dev, "Unable to read date\n");
220 return -EIO; 220 return err;
221 } 221 }
222 222
223 tm->tm_sec = bcd2bin(buf[M41T80_REG_SEC] & 0x7f); 223 tm->tm_sec = bcd2bin(buf[M41T80_REG_SEC] & 0x7f);
@@ -274,10 +274,11 @@ static int m41t80_rtc_set_time(struct device *dev, struct rtc_time *tm)
274 if (flags < 0) 274 if (flags < 0)
275 return flags; 275 return flags;
276 276
277 if (i2c_smbus_write_byte_data(client, M41T80_REG_FLAGS, 277 err = i2c_smbus_write_byte_data(client, M41T80_REG_FLAGS,
278 flags & ~M41T80_FLAGS_OF)) { 278 flags & ~M41T80_FLAGS_OF);
279 if (err < 0) {
279 dev_err(&client->dev, "Unable to write flags register\n"); 280 dev_err(&client->dev, "Unable to write flags register\n");
280 return -EIO; 281 return err;
281 } 282 }
282 283
283 return err; 284 return err;
@@ -287,10 +288,12 @@ static int m41t80_rtc_proc(struct device *dev, struct seq_file *seq)
287{ 288{
288 struct i2c_client *client = to_i2c_client(dev); 289 struct i2c_client *client = to_i2c_client(dev);
289 struct m41t80_data *clientdata = i2c_get_clientdata(client); 290 struct m41t80_data *clientdata = i2c_get_clientdata(client);
290 u8 reg; 291 int reg;
291 292
292 if (clientdata->features & M41T80_FEATURE_BL) { 293 if (clientdata->features & M41T80_FEATURE_BL) {
293 reg = i2c_smbus_read_byte_data(client, M41T80_REG_FLAGS); 294 reg = i2c_smbus_read_byte_data(client, M41T80_REG_FLAGS);
295 if (reg < 0)
296 return reg;
294 seq_printf(seq, "battery\t\t: %s\n", 297 seq_printf(seq, "battery\t\t: %s\n",
295 (reg & M41T80_FLAGS_BATT_LOW) ? "exhausted" : "ok"); 298 (reg & M41T80_FLAGS_BATT_LOW) ? "exhausted" : "ok");
296 } 299 }
@@ -393,7 +396,7 @@ static int m41t80_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
393 alrm->time.tm_min = bcd2bin(alarmvals[3] & 0x7f); 396 alrm->time.tm_min = bcd2bin(alarmvals[3] & 0x7f);
394 alrm->time.tm_hour = bcd2bin(alarmvals[2] & 0x3f); 397 alrm->time.tm_hour = bcd2bin(alarmvals[2] & 0x3f);
395 alrm->time.tm_mday = bcd2bin(alarmvals[1] & 0x3f); 398 alrm->time.tm_mday = bcd2bin(alarmvals[1] & 0x3f);
396 alrm->time.tm_mon = bcd2bin(alarmvals[0] & 0x3f); 399 alrm->time.tm_mon = bcd2bin(alarmvals[0] & 0x3f) - 1;
397 400
398 alrm->enabled = !!(alarmvals[0] & M41T80_ALMON_AFE); 401 alrm->enabled = !!(alarmvals[0] & M41T80_ALMON_AFE);
399 alrm->pending = (flags & M41T80_FLAGS_AF) && alrm->enabled; 402 alrm->pending = (flags & M41T80_FLAGS_AF) && alrm->enabled;
@@ -939,11 +942,7 @@ static int m41t80_probe(struct i2c_client *client,
939 if (m41t80_data->features & M41T80_FEATURE_HT) { 942 if (m41t80_data->features & M41T80_FEATURE_HT) {
940 m41t80_rtc_read_time(&client->dev, &tm); 943 m41t80_rtc_read_time(&client->dev, &tm);
941 dev_info(&client->dev, "HT bit was set!\n"); 944 dev_info(&client->dev, "HT bit was set!\n");
942 dev_info(&client->dev, 945 dev_info(&client->dev, "Power Down at %ptR\n", &tm);
943 "Power Down at %04i-%02i-%02i %02i:%02i:%02i\n",
944 tm.tm_year + 1900,
945 tm.tm_mon + 1, tm.tm_mday, tm.tm_hour,
946 tm.tm_min, tm.tm_sec);
947 } 946 }
948 rc = i2c_smbus_write_byte_data(client, M41T80_REG_ALARM_HOUR, 947 rc = i2c_smbus_write_byte_data(client, M41T80_REG_ALARM_HOUR,
949 rc & ~M41T80_ALHOUR_HT); 948 rc & ~M41T80_ALHOUR_HT);