]> Git Repo - linux.git/commitdiff
rtc: s5m: set range
authorAlexandre Belloni <[email protected]>
Wed, 4 Aug 2021 10:41:32 +0000 (12:41 +0200)
committerAlexandre Belloni <[email protected]>
Fri, 6 Aug 2021 08:31:59 +0000 (10:31 +0200)
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 <[email protected]>
Reviewed-by: Krzysztof Kozlowski <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
drivers/rtc/rtc-s5m.c

index 87df797758fc03cdd2176a2aa19efd1be3adf37f..fb9c6b709e1364d1606635c7ae8d24986b575873 100644 (file)
@@ -204,15 +204,9 @@ static int s5m8767_tm_to_data(struct rtc_time *tm, u8 *data)
        data[RTC_WEEKDAY] = 1 << tm->tm_wday;
        data[RTC_DATE] = tm->tm_mday;
        data[RTC_MONTH] = tm->tm_mon + 1;
-       data[RTC_YEAR1] = tm->tm_year > 100 ? (tm->tm_year - 100) : 0;
+       data[RTC_YEAR1] = tm->tm_year - 100;
 
-       if (tm->tm_year < 100) {
-               pr_err("RTC cannot handle the year %d\n",
-                      1900 + tm->tm_year);
-               return -EINVAL;
-       } else {
-               return 0;
-       }
+       return 0;
 }
 
 /*
@@ -792,6 +786,14 @@ static int s5m_rtc_probe(struct platform_device *pdev)
 
        info->rtc_dev->ops = &s5m_rtc_ops;
 
+       if (info->device_type == S5M8763X) {
+               info->rtc_dev->range_min = RTC_TIMESTAMP_BEGIN_0000;
+               info->rtc_dev->range_max = RTC_TIMESTAMP_END_9999;
+       } else {
+               info->rtc_dev->range_min = RTC_TIMESTAMP_BEGIN_2000;
+               info->rtc_dev->range_max = RTC_TIMESTAMP_END_2099;
+       }
+
        if (!info->irq) {
                clear_bit(RTC_FEATURE_ALARM, info->rtc_dev->features);
        } else {
This page took 0.06039 seconds and 4 git commands to generate.