Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+10 -8
+10 -8
drivers/rtc/rtc-s5m.c
··· 204 204 data[RTC_WEEKDAY] = 1 << tm->tm_wday; 205 205 data[RTC_DATE] = tm->tm_mday; 206 206 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; 208 208 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; 216 210 } 217 211 218 212 /* ··· 785 791 return PTR_ERR(info->rtc_dev); 786 792 787 793 info->rtc_dev->ops = &s5m_rtc_ops; 794 + 795 + if (info->device_type == S5M8763X) { 796 + info->rtc_dev->range_min = RTC_TIMESTAMP_BEGIN_0000; 797 + info->rtc_dev->range_max = RTC_TIMESTAMP_END_9999; 798 + } else { 799 + info->rtc_dev->range_min = RTC_TIMESTAMP_BEGIN_2000; 800 + info->rtc_dev->range_max = RTC_TIMESTAMP_END_2099; 801 + } 788 802 789 803 if (!info->irq) { 790 804 clear_bit(RTC_FEATURE_ALARM, info->rtc_dev->features);