Linux-RTC Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 1/4] rtc: fsl-ftm-alarm: allow COMPILE_TEST
@ 2019-10-16 20:12 Alexandre Belloni
  2019-10-16 20:12 ` [PATCH 2/4] rtc: fsl-ftm-alarm: switch to ktime_get_real_seconds Alexandre Belloni
                   ` (2 more replies)
  0 siblings, 3 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

Allow building building the driver with COMPILE_TEST.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index f28aee483c55..4185b0d27021 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -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
-- 
2.21.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [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	[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	[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	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 4/4] rtc: fsl-ftm-alarm: avoid struct rtc_time conversions Alexandre Belloni

Linux-RTC Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-rtc/0 linux-rtc/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-rtc linux-rtc/ https://lore.kernel.org/linux-rtc \
		linux-rtc@vger.kernel.org
	public-inbox-index linux-rtc

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-rtc


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git