Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 299059
b: refs/heads/master
c: bb58da0
h: refs/heads/master
i:
  299057: fd3c19b
  299055: a23e860
v: v3
  • Loading branch information
Andreas Dumberger authored and Linus Torvalds committed Apr 12, 2012
1 parent 1ca0c47 commit cf5c4e8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 44e4360fa3384850d65dd36fb4e6e5f2f112709b
refs/heads/master: bb58da08f01ee12561867fcd4385b82679ae7f6c
22 changes: 22 additions & 0 deletions trunk/drivers/rtc/rtc-r9701.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ static const struct rtc_class_ops r9701_rtc_ops = {
static int __devinit r9701_probe(struct spi_device *spi)
{
struct rtc_device *rtc;
struct rtc_time dt;
unsigned char tmp;
int res;

Expand All @@ -132,6 +133,27 @@ static int __devinit r9701_probe(struct spi_device *spi)
return -ENODEV;
}

/*
* The device seems to be present. Now check if the registers
* contain invalid values. If so, try to write a default date:
* 2000/1/1 00:00:00
*/
r9701_get_datetime(&spi->dev, &dt);
if (rtc_valid_tm(&dt)) {
dev_info(&spi->dev, "trying to repair invalid date/time\n");
dt.tm_sec = 0;
dt.tm_min = 0;
dt.tm_hour = 0;
dt.tm_mday = 1;
dt.tm_mon = 0;
dt.tm_year = 100;

if (r9701_set_datetime(&spi->dev, &dt)) {
dev_err(&spi->dev, "cannot repair RTC register\n");
return -ENODEV;
}
}

rtc = rtc_device_register("r9701",
&spi->dev, &r9701_rtc_ops, THIS_MODULE);
if (IS_ERR(rtc))
Expand Down

0 comments on commit cf5c4e8

Please sign in to comment.