Skip to contentSkip to conversation

rtc: use ktime_get_real_ts64() instead of getnstimeofday64()

PATCH RESEND In review Arnd Bergmann 2 participants 2 messages Jul 11, 2018 – Jul 13, 2018 Real time clock (RTC)

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 rtc: use ktime_get_real_ts64() instead of getnstimeofday64()

getnstimeofday64() is just a wrapper around the ktime accessor, so we should use that directly.

I considered using ktime_get_boottime_ts64() (to avoid leap second problems) or ktime_get_real_seconds() (to simplify the calculation, but in the end concluded that the existing interface is probably the most appropriate in this case.

---
Originally sent on Jun 18, but got no reply

Alexandre, could you pick this up into the rtc tree?

---
 drivers/rtc/class.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/rtc/class.c +2 -2
index d37588f08055..7fa32c922617 100644
@@ -68,7 +68,7 @@ static int rtc_suspend(struct device *dev)
 		return 0;
 	}
 
-	getnstimeofday64(&old_system);
+	ktime_get_real_ts64(&old_system);
 	old_rtc.tv_sec = rtc_tm_to_time64(&tm);
 
 
@@ -110,7 +110,7 @@ static int rtc_resume(struct device *dev)
 		return 0;
 
 	/* snapshot the current rtc and system time at resume */
-	getnstimeofday64(&new_system);
+	ktime_get_real_ts64(&new_system);
 	err = rtc_read_time(rtc, &tm);
 	if (err < 0) {
 		pr_debug("%s:  fail to read rtc time\n", dev_name(&rtc->dev));
Signature · 1 line
2.9.0
#1 lore raw
Quoted 8 lines · Arnd Bergmann

getnstimeofday64() is just a wrapper around the ktime accessor, so we should use that directly.

I considered using ktime_get_boottime_ts64() (to avoid leap second problems) or ktime_get_real_seconds() (to simplify the calculation, but in the end concluded that the existing interface is probably the most appropriate in this case.

Quoted 5 lines

---
Originally sent on Jun 18, but got no reply

Alexandre, could you pick this up into the rtc tree?

Yes, I've been late in my reviews lately. It is applied now.

I had some trouble figuring out that ktime_get_real_ts64 was not a macro anymore as I was still looking at 4.17 ;)

Quoted 29 lines
---
 drivers/rtc/class.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/rtc/class.c +2 -2
index d37588f08055..7fa32c922617 100644
@@ -68,7 +68,7 @@ static int rtc_suspend(struct device *dev)
 		return 0;
 	}
 
-	getnstimeofday64(&old_system);
+	ktime_get_real_ts64(&old_system);
 	old_rtc.tv_sec = rtc_tm_to_time64(&tm);
 
 
@@ -110,7 +110,7 @@ static int rtc_resume(struct device *dev)
 		return 0;
 
 	/* snapshot the current rtc and system time at resume */
-	getnstimeofday64(&new_system);
+	ktime_get_real_ts64(&new_system);
 	err = rtc_read_time(rtc, &tm);
 	if (err < 0) {
 		pr_debug("%s:  fail to read rtc time\n", dev_name(&rtc->dev));
Signature · 1 line
2.9.0
Signature · 3 lines
Alexandre Belloni, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com