public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Leonid Bloch <lb.workbox@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: John Stultz <john.stultz@linaro.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Stephen Boyd <sboyd@kernel.org>,
	Leonid Bloch <lb.workbowx@gmail.com>
Subject: [PATCH] rtc: Do not sync CMOS clock when CONFIG_RTC_SYSTOHC is not set
Date: Thu,  9 Apr 2020 23:46:07 +0300	[thread overview]
Message-ID: <20200409204607.8280-1-lb.workbox@gmail.com> (raw)

According to documentation in 'drivers/rtc/Kconfig', if
'CONFIG_RTC_SYSTOHC' is set, then:

'''
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.
'''

However in reality, even if 'CONFIG_RTC_SYSTOHC' is not set, the RTC
is still sometimes synced with the system time: at least when the RTC
driver is 'rtc_cmos', in certain situations. This commit prevents that.

Signed-off-by: Leonid Bloch <lb.workbox@gmail.com>
---
 kernel/time/ntp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index 069ca78fb0bf..58260ca75c64 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -535,9 +535,6 @@ static void sync_rtc_clock(void)
 	struct timespec64 adjust, now;
 	int rc;
 
-	if (!IS_ENABLED(CONFIG_RTC_SYSTOHC))
-		return;
-
 	ktime_get_real_ts64(&now);
 
 	adjust = now;
@@ -613,6 +610,9 @@ static bool sync_cmos_clock(void)
  */
 static void sync_hw_clock(struct work_struct *work)
 {
+	if (!IS_ENABLED(CONFIG_RTC_SYSTOHC))
+		return;
+
 	if (!ntp_synced())
 		return;
 
-- 
2.26.0


             reply	other threads:[~2020-04-09 20:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-09 20:46 Leonid Bloch [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-04-26  1:35 [PATCH] rtc: Do not sync CMOS clock when CONFIG_RTC_SYSTOHC is not set Leonid Bloch
2020-04-27  9:30 ` Thomas Gleixner
2020-04-27 14:36   ` Leonid Bloch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200409204607.8280-1-lb.workbox@gmail.com \
    --to=lb.workbox@gmail.com \
    --cc=john.stultz@linaro.org \
    --cc=lb.workbowx@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sboyd@kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox