* [PATCH 2/4] rtc: fsl-ftm-alarm: switch to ktime_get_real_seconds
2019-10-16 20:12 [PATCH 1/4] rtc: fsl-ftm-alarm: allow COMPILE_TEST Alexandre Belloni
@ 2019-10-16 20:12 ` Alexandre Belloni
2019-10-16 20:12 ` [PATCH 3/4] rtc: fsl-ftm-alarm: switch to rtc_time64_to_tm/rtc_tm_to_time64 Alexandre Belloni
2019-10-16 20:12 ` [PATCH 4/4] rtc: fsl-ftm-alarm: avoid struct rtc_time conversions Alexandre Belloni
2 siblings, 0 replies; 4+ messages in thread
From: Alexandre Belloni @ 2019-10-16 20:12 UTC (permalink / raw)
To: linux-rtc; +Cc: Biwen Li, Li Yang, linux-kernel, Alexandre Belloni
The driver drops the nanoseconds part of the timespec64, there is no need
to call ktime_get_real_ts64.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-fsl-ftm-alarm.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/rtc/rtc-fsl-ftm-alarm.c b/drivers/rtc/rtc-fsl-ftm-alarm.c
index b83f7afa8311..e954c51bf39b 100644
--- a/drivers/rtc/rtc-fsl-ftm-alarm.c
+++ b/drivers/rtc/rtc-fsl-ftm-alarm.c
@@ -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;
}
--
2.21.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/4] rtc: fsl-ftm-alarm: switch to rtc_time64_to_tm/rtc_tm_to_time64
2019-10-16 20:12 [PATCH 1/4] rtc: fsl-ftm-alarm: allow COMPILE_TEST Alexandre Belloni
2019-10-16 20:12 ` [PATCH 2/4] rtc: fsl-ftm-alarm: switch to ktime_get_real_seconds Alexandre Belloni
@ 2019-10-16 20:12 ` Alexandre Belloni
2019-10-16 20:12 ` [PATCH 4/4] rtc: fsl-ftm-alarm: avoid struct rtc_time conversions Alexandre Belloni
2 siblings, 0 replies; 4+ messages in thread
From: Alexandre Belloni @ 2019-10-16 20:12 UTC (permalink / raw)
To: linux-rtc; +Cc: Biwen Li, Li Yang, linux-kernel, Alexandre Belloni
Call the 64bit versions of rtc_tm time conversion to avoid the y2038 issue.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-fsl-ftm-alarm.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/rtc/rtc-fsl-ftm-alarm.c b/drivers/rtc/rtc-fsl-ftm-alarm.c
index e954c51bf39b..039bd2f1a7ee 100644
--- a/drivers/rtc/rtc-fsl-ftm-alarm.c
+++ b/drivers/rtc/rtc-fsl-ftm-alarm.c
@@ -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;
--
2.21.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 4/4] rtc: fsl-ftm-alarm: avoid struct rtc_time conversions
2019-10-16 20:12 [PATCH 1/4] rtc: fsl-ftm-alarm: allow COMPILE_TEST Alexandre Belloni
2019-10-16 20:12 ` [PATCH 2/4] rtc: fsl-ftm-alarm: switch to ktime_get_real_seconds Alexandre Belloni
2019-10-16 20:12 ` [PATCH 3/4] rtc: fsl-ftm-alarm: switch to rtc_time64_to_tm/rtc_tm_to_time64 Alexandre Belloni
@ 2019-10-16 20:12 ` Alexandre Belloni
2 siblings, 0 replies; 4+ messages in thread
From: Alexandre Belloni @ 2019-10-16 20:12 UTC (permalink / raw)
To: linux-rtc; +Cc: Biwen Li, Li Yang, linux-kernel, Alexandre Belloni
Directly 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 <alexandre.belloni@bootlin.com>
---
drivers/rtc/rtc-fsl-ftm-alarm.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/rtc/rtc-fsl-ftm-alarm.c b/drivers/rtc/rtc-fsl-ftm-alarm.c
index 039bd2f1a7ee..9e6e994cce99 100644
--- a/drivers/rtc/rtc-fsl-ftm-alarm.c
+++ b/drivers/rtc/rtc-fsl-ftm-alarm.c
@@ -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;
--
2.21.0
^ permalink raw reply related [flat|nested] 4+ messages in thread