summaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-rx8581.c
diff options
context:
space:
mode:
authorAlexandre Belloni <alexandre.belloni@bootlin.com>2018-05-17 16:33:27 -0400
committerAlexandre Belloni <alexandre.belloni@bootlin.com>2018-05-17 16:37:16 -0400
commitc6e3c297a1948095c248058fd4ba51b1f9d12e7f (patch)
treec57647015b58aac3e27f7fdafbba997bad8bc292 /drivers/rtc/rtc-rx8581.c
parent86c54ef6e607ff190cd3464dfd8eba5b77388ea6 (diff)
rtc: rx8581: let the core handle rtc range
Let the core handle offsetting and windowing the RTC range. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Diffstat (limited to 'drivers/rtc/rtc-rx8581.c')
-rw-r--r--drivers/rtc/rtc-rx8581.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/rtc/rtc-rx8581.c b/drivers/rtc/rtc-rx8581.c
index c5ffd30ca672..171ee241bd2f 100644
--- a/drivers/rtc/rtc-rx8581.c
+++ b/drivers/rtc/rtc-rx8581.c
@@ -153,10 +153,7 @@ static int rx8581_get_datetime(struct i2c_client *client, struct rtc_time *tm)
153 tm->tm_wday = ilog2(date[RX8581_REG_DW] & 0x7F); 153 tm->tm_wday = ilog2(date[RX8581_REG_DW] & 0x7F);
154 tm->tm_mday = bcd2bin(date[RX8581_REG_DM] & 0x3F); 154 tm->tm_mday = bcd2bin(date[RX8581_REG_DM] & 0x3F);
155 tm->tm_mon = bcd2bin(date[RX8581_REG_MO] & 0x1F) - 1; /* rtc mn 1-12 */ 155 tm->tm_mon = bcd2bin(date[RX8581_REG_MO] & 0x1F) - 1; /* rtc mn 1-12 */
156 tm->tm_year = bcd2bin(date[RX8581_REG_YR]); 156 tm->tm_year = bcd2bin(date[RX8581_REG_YR]) + 100;
157 if (tm->tm_year < 70)
158 tm->tm_year += 100; /* assume we are in 1970...2069 */
159
160 157
161 dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, " 158 dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, "
162 "mday=%d, mon=%d, year=%d, wday=%d\n", 159 "mday=%d, mon=%d, year=%d, wday=%d\n",
@@ -190,7 +187,7 @@ static int rx8581_set_datetime(struct i2c_client *client, struct rtc_time *tm)
190 buf[RX8581_REG_MO] = bin2bcd(tm->tm_mon + 1); 187 buf[RX8581_REG_MO] = bin2bcd(tm->tm_mon + 1);
191 188
192 /* year and century */ 189 /* year and century */
193 buf[RX8581_REG_YR] = bin2bcd(tm->tm_year % 100); 190 buf[RX8581_REG_YR] = bin2bcd(tm->tm_year - 100);
194 buf[RX8581_REG_DW] = (0x1 << tm->tm_wday); 191 buf[RX8581_REG_DW] = (0x1 << tm->tm_wday);
195 192
196 /* Stop the clock */ 193 /* Stop the clock */
@@ -293,6 +290,8 @@ static int rx8581_probe(struct i2c_client *client,
293 rx8581->rtc->ops = &rx8581_rtc_ops; 290 rx8581->rtc->ops = &rx8581_rtc_ops;
294 rx8581->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000; 291 rx8581->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
295 rx8581->rtc->range_max = RTC_TIMESTAMP_END_2099; 292 rx8581->rtc->range_max = RTC_TIMESTAMP_END_2099;
293 rx8581->rtc->start_secs = 0;
294 rx8581->rtc->set_start_time = true;
296 295
297 return rtc_register_device(rx8581->rtc); 296 return rtc_register_device(rx8581->rtc);
298} 297}