Subject: Re: [RFC PATCH] rtc: add rtc_systohc for ntp use

From: David Brownell <[email-masked]>
Date: Mon, 10 Nov 2008 14:57:28 -0800

Yeah, we should have one of these.  :)

On Monday 10 November 2008, Alessandro Zummo wrote:
> @@ -30,7 +30,7 @@ config RTC_HCTOSYS
>  	  unnecessary fsck runs at boot time, and to network better.
>  
>  config RTC_HCTOSYS_DEVICE
> -	string "RTC used to set the system time"
> +	string "RTC used to set the system time on startup and resume"
>  	depends on RTC_HCTOSYS = y
>  	default "rtc0"
>  	help
> @@ -52,6 +52,23 @@ 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 RTC from system time in NTP sync mode"
> +	depends on RTC_CLASS = y
> +	default y
> +	help
> +	  If you say yes here, the system time (wall clock) will be written
> +	  to the hardware clock every 11 minutes, if the kernel is in NTP
> +	  mode and your platforms supports it.
> +
> +config RTC_SYSTOHC_DEVICE
> +	string "RTC used to save the system time in NTP sync mode"

Why not just use RTC_HCTOSYS_DEVICE for this?  I have a hard time
sseeing any other value make sense ... assuming there's only one
RTC involved.

A better default might be to update all the RTCs on the system.

I'm thinking of my trusty test-case here:  rtc0 is highly functional
(including wake from RTC alarm) but not battery backed, while rtc1
is battery backed but only tracks time.  NTP really needs to update
both of them ... rtc0 since that's what's used most of the time,
and also rtc1 since that's what actually *stores* the time during
power off cycles.

> +static int rtc_systohc(struct rtc_time *tm)

I think "static" will lose, especially since ...

> +EXPORT_SYMBOL(rtc_systohc);

... you want other code to call it.