aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-r9701.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc/rtc-r9701.c')
-rw-r--r--drivers/rtc/rtc-r9701.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/rtc/rtc-r9701.c b/drivers/rtc/rtc-r9701.c
index 7f8e6c247935..33b6ba0afa0d 100644
--- a/drivers/rtc/rtc-r9701.c
+++ b/drivers/rtc/rtc-r9701.c
@@ -122,6 +122,7 @@ static const struct rtc_class_ops r9701_rtc_ops = {
122static int __devinit r9701_probe(struct spi_device *spi) 122static int __devinit r9701_probe(struct spi_device *spi)
123{ 123{
124 struct rtc_device *rtc; 124 struct rtc_device *rtc;
125 struct rtc_time dt;
125 unsigned char tmp; 126 unsigned char tmp;
126 int res; 127 int res;
127 128
@@ -132,6 +133,27 @@ static int __devinit r9701_probe(struct spi_device *spi)
132 return -ENODEV; 133 return -ENODEV;
133 } 134 }
134 135
136 /*
137 * The device seems to be present. Now check if the registers
138 * contain invalid values. If so, try to write a default date:
139 * 2000/1/1 00:00:00
140 */
141 r9701_get_datetime(&spi->dev, &dt);
142 if (rtc_valid_tm(&dt)) {
143 dev_info(&spi->dev, "trying to repair invalid date/time\n");
144 dt.tm_sec = 0;
145 dt.tm_min = 0;
146 dt.tm_hour = 0;
147 dt.tm_mday = 1;
148 dt.tm_mon = 0;
149 dt.tm_year = 100;
150
151 if (r9701_set_datetime(&spi->dev, &dt)) {
152 dev_err(&spi->dev, "cannot repair RTC register\n");
153 return -ENODEV;
154 }
155 }
156
135 rtc = rtc_device_register("r9701", 157 rtc = rtc_device_register("r9701",
136 &spi->dev, &r9701_rtc_ops, THIS_MODULE); 158 &spi->dev, &r9701_rtc_ops, THIS_MODULE);
137 if (IS_ERR(rtc)) 159 if (IS_ERR(rtc))