Skip to contentSkip to conversation

rtc: sun4v: switch to rtc_time64_to_tm/rtc_tm_to_time64

PATCH In review Alexandre Belloni 2 participants 6 messages Mar 22, 2019 – Mar 24, 2019 Real time clock (RTC)

lore
Share & tools
lore

Alexandre Belloni

author maintainer
#0 lore raw

PATCH 1/3 rtc: sun4v: switch to rtc_time64_to_tm/rtc_tm_to_time64

Call the 64bit versions of rtc_tm time conversion as the hypervisor handles 64bit values.

---
 drivers/rtc/rtc-sun4v.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/rtc/rtc-sun4v.c +2 -9
index 11bc562eba5d..378081fffa91 100644
@@ -39,7 +39,7 @@ static unsigned long hypervisor_get_time(void)
 
 static int sun4v_read_time(struct device *dev, struct rtc_time *tm)
 {
-	rtc_time_to_tm(hypervisor_get_time(), tm);
+	rtc_time64_to_tm(hypervisor_get_time(), tm);
 	return 0;
 }
 
@@ -66,14 +66,7 @@ static int hypervisor_set_time(unsigned long secs)
 
 static int sun4v_set_time(struct device *dev, struct rtc_time *tm)
 {
-	unsigned long secs;
-	int err;
-
-	err = rtc_tm_to_time(tm, &secs);
-	if (err)
-		return err;
-
-	return hypervisor_set_time(secs);
+	return hypervisor_set_time(rtc_tm_to_time64(tm));
 }
 
 static const struct rtc_class_ops sun4v_rtc_ops = {
Signature · 1 line
2.20.1
author maintainer
#1 lore raw

PATCH 2/3 rtc: sun4v: set range

The Sun4v Hypervisor Core API Specification states:
Time is described by a single unsigned 64-bit word equivalent to a time_t for the POSIX time(2) system call. The word contains the time since the Epoch (00:00:00 UTC, January 1, 1970), measured in seconds.

---
 drivers/rtc/rtc-sun4v.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/rtc/rtc-sun4v.c +5 -3
index 378081fffa91..82fb51f79c6e 100644
@@ -78,13 +78,15 @@ static int __init sun4v_rtc_probe(struct platform_device *pdev)
 {
 	struct rtc_device *rtc;
 
-	rtc = devm_rtc_device_register(&pdev->dev, "sun4v",
-				&sun4v_rtc_ops, THIS_MODULE);
+	rtc = devm_rtc_allocate_device(&pdev->dev);
 	if (IS_ERR(rtc))
 		return PTR_ERR(rtc);
 
+	rtc->ops = &sun4v_rtc_ops;
+	rtc->range_max = U64_MAX;
 	platform_set_drvdata(pdev, rtc);
-	return 0;
+
+	return rtc_register_device(rtc);
 }
 
 static struct platform_driver sun4v_rtc_driver = {
Signature · 1 line
2.20.1
Acked-by on v1 2/3
#2 lore raw

Re: [PATCH 2/3] rtc: sun4v: set range

From: Alexandre Belloni <[email protected]>
Date: Fri, 22 Mar 2019 08:22:55 +0100

Quoted 6 lines

The Sun4v Hypervisor Core API Specification states:
Time is described by a single unsigned 64-bit word equivalent to a time_t for the POSIX time(2) system call. The word contains the time since the Epoch (00:00:00 UTC, January 1, 1970), measured in seconds.

author maintainer
#3 lore raw

PATCH 3/3 rtc: sun4v: switch to SPDX identifier

In reply to Alexandre Belloni

Use SPDX-License-Identifier to be clearer on the license. Choose the v2 only as this is the default Linux license.

---
 drivers/rtc/rtc-sun4v.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-sun4v.c +1 -1
index 82fb51f79c6e..036463dfa103 100644
@@ -1,7 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /* rtc-sun4v.c: Hypervisor based RTC for SUN4V systems.
  *
  * Author: David S. Miller
- * License: GPL
  *
  * Copyright (C) 2008 David S. Miller <[email protected]>
  */
Signature · 1 line
2.20.1