Skip to content

Commit fffd603

Browse files
rtc: s5m: set range
The S5M8763X type seems to handles dates from year 0000 to 9999, there is no info on leap year handling after 2099. The other models handles dates from 2000 to 2099. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> Link: https://lore.kernel.org/r/20210804104133.5158-4-alexandre.belloni@bootlin.com
1 parent 308247d commit fffd603

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

drivers/rtc/rtc-s5m.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,9 @@ static int s5m8767_tm_to_data(struct rtc_time *tm, u8 *data)
204204
data[RTC_WEEKDAY] = 1 << tm->tm_wday;
205205
data[RTC_DATE] = tm->tm_mday;
206206
data[RTC_MONTH] = tm->tm_mon + 1;
207-
data[RTC_YEAR1] = tm->tm_year > 100 ? (tm->tm_year - 100) : 0;
207+
data[RTC_YEAR1] = tm->tm_year - 100;
208208

209-
if (tm->tm_year < 100) {
210-
pr_err("RTC cannot handle the year %d\n",
211-
1900 + tm->tm_year);
212-
return -EINVAL;
213-
} else {
214-
return 0;
215-
}
209+
return 0;
216210
}
217211

218212
/*
@@ -792,6 +786,14 @@ static int s5m_rtc_probe(struct platform_device *pdev)
792786

793787
info->rtc_dev->ops = &s5m_rtc_ops;
794788

789+
if (info->device_type == S5M8763X) {
790+
info->rtc_dev->range_min = RTC_TIMESTAMP_BEGIN_0000;
791+
info->rtc_dev->range_max = RTC_TIMESTAMP_END_9999;
792+
} else {
793+
info->rtc_dev->range_min = RTC_TIMESTAMP_BEGIN_2000;
794+
info->rtc_dev->range_max = RTC_TIMESTAMP_END_2099;
795+
}
796+
795797
if (!info->irq) {
796798
clear_bit(RTC_FEATURE_ALARM, info->rtc_dev->features);
797799
} else {

0 commit comments

Comments
 (0)