History

rtc: sh: set range

The SH RTC is a BCD RTC with some version having 4 digits for the year. The range for the RTCs with only 2 digits for the year was unfortunately shifted to handle 1999 to 2098.

Alexandre Belloni committed 7 years ago

Commit beee05d1 parent 10979982 files · +9 −0Browse files

Unified · Split

2 files
  1. drivers/rtc/rtc-sh.c +8 −0
  2. include/linux/rtc.h +1 −0
drivers/rtc/rtc-sh.c+8−0
@@ -600,6 +600,14 @@ static int __init sh_rtc_probe(struct platform_device *pdev) · 599 unmodified lines
600600 rtc->rtc_dev->ops = &sh_rtc_ops;
601601 rtc->rtc_dev->max_user_freq = 256;
602602
603+ if (rtc->capabilities & RTC_CAP_4_DIGIT_YEAR) {
604+ rtc->rtc_dev->range_min = RTC_TIMESTAMP_BEGIN_1900;
605+ rtc->rtc_dev->range_max = RTC_TIMESTAMP_END_9999;
606+ } else {
607+ rtc->rtc_dev->range_min = mktime64(1999, 1, 1, 0, 0, 0);
608+ rtc->rtc_dev->range_max = mktime64(2098, 12, 31, 23, 59, 59);
609+ }
610+
603611 ret = rtc_register_device(rtc->rtc_dev);
604612 if (ret)
605613 goto err_unmap;
include/linux/rtc.h+1−0
@@ -165,6 +165,7 @@ struct rtc_device { · 164 unmodified lines
165165 #define RTC_TIMESTAMP_BEGIN_1900 -2208989361LL /* 1900-01-01 00:00:00 */
166166 #define RTC_TIMESTAMP_BEGIN_2000 946684800LL /* 2000-01-01 00:00:00 */
167167 #define RTC_TIMESTAMP_END_2099 4102444799LL /* 2099-12-31 23:59:59 */
168+#define RTC_TIMESTAMP_END_9999 253402300799LL /* 9999-12-31 23:59:59 */
168169
169170 extern struct rtc_device *devm_rtc_device_register(struct device *dev,
170171 const char *name,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t