diff mbox

[v2,1/4] NTP: rtc: Add CONFIG_RTC_SYSTOHC_DEVICE for NTP synchronization

Message ID 1432910778-314-1-git-send-email-xlpang@126.com
State Not Applicable
Delegated to: David Miller
Headers show

Commit Message

Xunlei Pang May 29, 2015, 2:46 p.m. UTC
From: Xunlei Pang <pang.xunlei@linaro.org>

Currently, CONFIG_RTC_SYSTOHC uses CONFIG_RTC_HCTOSYS_DEVICE which
is originally used by CONFIG_RTC_HCTOSYS, but this rtc device has
some limiations, for example, it must be battery-backed, be able
to work with irq off and through system suspension, etc.

So add CONFIG_RTC_SYSTOHC_DEVICE used exclusively for CONFIG_RTC_SYSTOHC,
it is more lenient compared to CONFIG_RTC_HCTOSYS_DEVICE, and could
be assigned any available RTC in the system. Default value is "rtc0".

After this patch, NTP will sync up "rtc0" by default.

Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
---
 drivers/rtc/Kconfig   | 28 +++++++++++++++++++---------
 drivers/rtc/systohc.c |  2 +-
 2 files changed, 20 insertions(+), 10 deletions(-)

Comments

Paul Bolle June 1, 2015, 8:27 a.m. UTC | #1
On Fri, 2015-05-29 at 22:46 +0800, Xunlei Pang wrote:
> --- a/drivers/rtc/Kconfig
> +++ b/drivers/rtc/Kconfig

>  config RTC_HCTOSYS_DEVICE
>  	string "RTC used to set the system time"
> -	depends on RTC_HCTOSYS = y || RTC_SYSTOHC = y
> +	depends on RTC_HCTOSYS = y

RTC_HCTOSYS and RTC_SYSTOHC are bool symbols. The "= y" test is not
needed and the common idiom is to use only
	depends on RTC_HCTOSYS

Since you're touching this you might as well switch to that idiom.

>  	default "rtc0"
>  	help
>  	  The RTC device that will be used to (re)initialize the system
> 	  minutes if userspace reports synchronized NTP status.

> +config RTC_SYSTOHC_DEVICE
> +	string "RTC used to synchronize NTP adjustment"
> +	depends on RTC_SYSTOHC = y

Likewise.

> +	default "rtc0"
> +	help
> +	  The RTC device used for NTP synchronization. The main difference
> +	  between RTC_HCTOSYS_DEVICE and RTC_SYSTOHC_DEVICE is that this
> +	  one can sleep when setting time, because it runs in the workqueue
> +	  context.


Paul Bolle

--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
pang.xunlei@zte.com.cn June 2, 2015, 3:18 a.m. UTC | #2
Hi Paul,

Paul Bolle <pebolle@tiscali.nl> wrote 2015-06-01 PM 04:27:40:
> 
> Re: [PATCH v2 1/4] NTP: rtc: Add CONFIG_RTC_SYSTOHC_DEVICE for NTP 
> synchronization
> 
> On Fri, 2015-05-29 at 22:46 +0800, Xunlei Pang wrote:
> > --- a/drivers/rtc/Kconfig
> > +++ b/drivers/rtc/Kconfig
> 
> >  config RTC_HCTOSYS_DEVICE
> >     string "RTC used to set the system time"
> > -   depends on RTC_HCTOSYS = y || RTC_SYSTOHC = y
> > +   depends on RTC_HCTOSYS = y
> 
> RTC_HCTOSYS and RTC_SYSTOHC are bool symbols. The "= y" test is not
> needed and the common idiom is to use only
>    depends on RTC_HCTOSYS
> 
> Since you're touching this you might as well switch to that idiom.
> 
> >     default "rtc0"
> >     help
> >       The RTC device that will be used to (re)initialize the system
> >      minutes if userspace reports synchronized NTP status.
> 
> > +config RTC_SYSTOHC_DEVICE
> > +   string "RTC used to synchronize NTP adjustment"
> > +   depends on RTC_SYSTOHC = y
> 
> Likewise.

Yea, thanks for pointing this out.

-Xunlei

> 
> > +   default "rtc0"
> > +   help
> > +     The RTC device used for NTP synchronization. The main difference
> > +     between RTC_HCTOSYS_DEVICE and RTC_SYSTOHC_DEVICE is that this
> > +     one can sleep when setting time, because it runs in the 
workqueue
> > +     context.
> 
> 
> Paul Bolle
> 

--------------------------------------------------------
ZTE Information Security Notice: The information contained in this mail (and any attachment transmitted herewith) is privileged and confidential and is intended for the exclusive use of the addressee(s).  If you are not an intended recipient, any disclosure, reproduction, distribution or other dissemination or use of the information contained is strictly prohibited.  If you have received this mail in error, please delete it and notify us immediately.
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 0fe4ad8..f429e9a 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -25,17 +25,9 @@  config RTC_HCTOSYS
 	  the value read from a specified RTC device. This is useful to avoid
 	  unnecessary fsck runs at boot time, and to network better.
 
-config RTC_SYSTOHC
-	bool "Set the RTC time based on NTP synchronization"
-	default y
-	help
-	  If you say yes here, the system time (wall clock) will be stored
-	  in the RTC specified by RTC_HCTOSYS_DEVICE approximately every 11
-	  minutes if userspace reports synchronized NTP status.
-
 config RTC_HCTOSYS_DEVICE
 	string "RTC used to set the system time"
-	depends on RTC_HCTOSYS = y || RTC_SYSTOHC = y
+	depends on RTC_HCTOSYS = y
 	default "rtc0"
 	help
 	  The RTC device that will be used to (re)initialize the system
@@ -56,6 +48,24 @@  config RTC_HCTOSYS_DEVICE
 	  sleep states. Do not specify an RTC here unless it stays powered
 	  during all this system's supported sleep states.
 
+config RTC_SYSTOHC
+	bool "Set the RTC time based on NTP synchronization"
+	default y
+	help
+	  If you say yes here, the system time (wall clock) will be stored
+	  in the RTC specified by RTC_HCTOSYS_DEVICE approximately every 11
+	  minutes if userspace reports synchronized NTP status.
+
+config RTC_SYSTOHC_DEVICE
+	string "RTC used to synchronize NTP adjustment"
+	depends on RTC_SYSTOHC = y
+	default "rtc0"
+	help
+	  The RTC device used for NTP synchronization. The main difference
+	  between RTC_HCTOSYS_DEVICE and RTC_SYSTOHC_DEVICE is that this
+	  one can sleep when setting time, because it runs in the workqueue
+	  context.
+
 config RTC_DEBUG
 	bool "RTC debug support"
 	help
diff --git a/drivers/rtc/systohc.c b/drivers/rtc/systohc.c
index 7728d5e..b4a68ff 100644
--- a/drivers/rtc/systohc.c
+++ b/drivers/rtc/systohc.c
@@ -31,7 +31,7 @@  int rtc_set_ntp_time(struct timespec64 now)
 	else
 		rtc_time64_to_tm(now.tv_sec + 1, &tm);
 
-	rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);
+	rtc = rtc_class_open(CONFIG_RTC_SYSTOHC_DEVICE);
 	if (rtc) {
 		/* rtc_hctosys exclusively uses UTC, so we call set_time here,
 		 * not set_mmss. */