rtc: fsl-ftm-alarm: allow COMPILE_TEST
Alexandre Belloni
maintainerPATCH 1/4 rtc: fsl-ftm-alarm: allow COMPILE_TEST
Allow building building the driver with COMPILE_TEST.
Signed-off-by Alexandre Belloni <[email protected]>
--- drivers/rtc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/Kconfig +1 -1
@@ -1325,7 +1325,7 @@ config RTC_DRV_IMXDI config RTC_DRV_FSL_FTM_ALARM tristate "Freescale FlexTimer alarm timer" - depends on ARCH_LAYERSCAPE || SOC_LS1021A + depends on ARCH_LAYERSCAPE || SOC_LS1021A || COMPILE_TEST select FSL_RCPM default y help
Signature · 1 line
2.21.0
Alexandre Belloni
maintainerPATCH 2/4 rtc: fsl-ftm-alarm: switch to ktime_get_real_seconds
The driver drops the nanoseconds part of the timespec64, there is no need to call ktime_get_real_ts64.
Signed-off-by Alexandre Belloni <[email protected]>
--- drivers/rtc/rtc-fsl-ftm-alarm.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/rtc/rtc-fsl-ftm-alarm.c +1 -4
@@ -180,10 +180,7 @@ static int ftm_rtc_alarm_irq_enable(struct device *dev,*/ static int ftm_rtc_read_time (struct device *dev,struct rtc_time *tm) { -struct timespec64 ts64; - -ktime_get_real_ts64 (&ts64); -rtc_time_to_tm (ts64.tv_sec, tm); +rtc_time_to_tm (ktime_get_real_seconds (), tm);return 0 ; }
Signature · 1 line
2.21.0
Alexandre Belloni
maintainerPATCH 3/4 rtc: fsl-ftm-alarm: switch to rtc_time64_to_tm/rtc_tm_to_time64
In reply to Alexandre BelloniCall the 64bit versions of rtc_tm time conversion to avoid the y2038 issue.
Signed-off-by Alexandre Belloni <[email protected]>
--- drivers/rtc/rtc-fsl-ftm-alarm.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/rtc/rtc-fsl-ftm-alarm.c +5 -4
@@ -180,7 +180,7 @@ static int ftm_rtc_alarm_irq_enable(struct device *dev,*/ static int ftm_rtc_read_time (struct device *dev,struct rtc_time *tm) { -rtc_time_to_tm (ktime_get_real_seconds (), tm); +rtc_time64_to_tm (ktime_get_real_seconds (), tm);return 0 ; }
@@ -204,12 +204,13 @@ static int ftm_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)static int ftm_rtc_set_alarm (struct device *dev,struct rtc_wkalrm *alm) {struct rtc_time tm; -unsigned long now, alm_time, cycle; +time64_t now, alm_time; +unsigned long long cycle;struct ftm_rtc *rtc =dev_get_drvdata (dev);ftm_rtc_read_time (dev, &tm); -rtc_tm_to_time (&tm, &now); -rtc_tm_to_time (&alm->time, &alm_time); + now =rtc_tm_to_time64 (&tm); + alm_time =rtc_tm_to_time64 (&alm->time);ftm_clean_alarm (rtc); cycle = (alm_time - now) * rtc->alarm_freq;
Signature · 1 line
2.21.0
Alexandre Belloni
maintainerPATCH 4/4 rtc: fsl-ftm-alarm: avoid struct rtc_time conversions
In reply to Alexandre BelloniDirectly call ktime_get_real_seconds instead of converting the result to a struct rtc_time and then back to a time64_t.
Signed-off-by Alexandre Belloni <[email protected]>
--- drivers/rtc/rtc-fsl-ftm-alarm.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/rtc/rtc-fsl-ftm-alarm.c +2 -5
@@ -203,17 +203,14 @@ static int ftm_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)*/ static int ftm_rtc_set_alarm (struct device *dev,struct rtc_wkalrm *alm) { -struct rtc_time tm; -time64_t now, alm_time; +time64_t alm_time;unsigned long long cycle;struct ftm_rtc *rtc =dev_get_drvdata (dev); -ftm_rtc_read_time (dev, &tm); - now =rtc_tm_to_time64 (&tm); alm_time =rtc_tm_to_time64 (&alm->time);ftm_clean_alarm (rtc); - cycle = (alm_time - now) * rtc->alarm_freq; + cycle = (alm_time -ktime_get_real_seconds ()) * rtc->alarm_freq;if (cycle >MAX_COUNT_VAL ) {pr_err ("Out of alarm range {0~262} seconds.\n" );return -ERANGE ;
Signature · 1 line
2.21.0