108
108
* driver, even though it is somewhat limited.
109
109
*/
110
110
#define SUN6I_YEAR_MIN 1970
111
- #define SUN6I_YEAR_MAX 2033
112
111
#define SUN6I_YEAR_OFF (SUN6I_YEAR_MIN - 1900)
113
112
114
113
/*
@@ -569,14 +568,6 @@ static int sun6i_rtc_settime(struct device *dev, struct rtc_time *rtc_tm)
569
568
struct sun6i_rtc_dev * chip = dev_get_drvdata (dev );
570
569
u32 date = 0 ;
571
570
u32 time = 0 ;
572
- int year ;
573
-
574
- year = rtc_tm -> tm_year + 1900 ;
575
- if (year < SUN6I_YEAR_MIN || year > SUN6I_YEAR_MAX ) {
576
- dev_err (dev , "rtc only supports year in range %d - %d\n" ,
577
- SUN6I_YEAR_MIN , SUN6I_YEAR_MAX );
578
- return - EINVAL ;
579
- }
580
571
581
572
rtc_tm -> tm_year -= SUN6I_YEAR_OFF ;
582
573
rtc_tm -> tm_mon += 1 ;
@@ -585,7 +576,7 @@ static int sun6i_rtc_settime(struct device *dev, struct rtc_time *rtc_tm)
585
576
SUN6I_DATE_SET_MON_VALUE (rtc_tm -> tm_mon ) |
586
577
SUN6I_DATE_SET_YEAR_VALUE (rtc_tm -> tm_year );
587
578
588
- if (is_leap_year (year ))
579
+ if (is_leap_year (rtc_tm -> tm_year + SUN6I_YEAR_MIN ))
589
580
date |= SUN6I_LEAP_SET_VALUE (1 );
590
581
591
582
time = SUN6I_TIME_SET_SEC_VALUE (rtc_tm -> tm_sec ) |
@@ -726,12 +717,16 @@ static int sun6i_rtc_probe(struct platform_device *pdev)
726
717
727
718
device_init_wakeup (& pdev -> dev , 1 );
728
719
729
- chip -> rtc = devm_rtc_device_register (& pdev -> dev , "rtc-sun6i" ,
730
- & sun6i_rtc_ops , THIS_MODULE );
731
- if (IS_ERR (chip -> rtc )) {
732
- dev_err (& pdev -> dev , "unable to register device\n" );
720
+ chip -> rtc = devm_rtc_allocate_device (& pdev -> dev );
721
+ if (IS_ERR (chip -> rtc ))
733
722
return PTR_ERR (chip -> rtc );
734
- }
723
+
724
+ chip -> rtc -> ops = & sun6i_rtc_ops ;
725
+ chip -> rtc -> range_max = 2019686399LL ; /* 2033-12-31 23:59:59 */
726
+
727
+ ret = rtc_register_device (chip -> rtc );
728
+ if (ret )
729
+ return ret ;
735
730
736
731
dev_info (& pdev -> dev , "RTC enabled\n" );
737
732
0 commit comments