public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: john stultz <johnstul@us.ibm.com>
To: lkml <linux-kernel@vger.kernel.org>
Cc: Russell King <linux@arm.linux.org.uk>,
	linux-arm-kernel@lists.infradead.org
Subject: [RFC][PATCH 2/14] Convert arm to read/update_persistent_clock
Date: Tue, 22 Dec 2009 20:01:42 -0800	[thread overview]
Message-ID: <1261540902.3508.63.camel@localhost.localdomain> (raw)
In-Reply-To: <1261540826.3508.62.camel@localhost.localdomain>

This patch converts the arm architecture to use the generic
read_persistent_clock and update_persistent_clock interfaces, reducing
the amount of arch specific code we have to maintain, and allowing for
further cleanups in the future.

Also removes a direct xtime access, replacing it with
current_kernel_time()

I have not built or tested this patch, so help from arch maintainers
would be appreciated.

Signed-off-by: John Stultz <johnstul@us.ibm.com>
---
 Kconfig                 |    3 +++
 include/asm/mach/time.h |    2 +-
 kernel/time.c           |   39 ++++++++-------------------------------
 mach-footbridge/time.c  |    4 ++--
 4 files changed, 14 insertions(+), 34 deletions(-)

Index: gettimeoffset/arch/arm/Kconfig
===================================================================
--- gettimeoffset.orig/arch/arm/Kconfig	2009-12-22 18:50:54.000000000 -0800
+++ gettimeoffset/arch/arm/Kconfig	2009-12-22 18:51:20.000000000 -0800
@@ -38,6 +38,9 @@ config GENERIC_GPIO
 config GENERIC_TIME
 	bool
 
+config GENERIC_CMOS_UPDATE
+        def_bool y
+
 config GENERIC_CLOCKEVENTS
 	bool
 
Index: gettimeoffset/arch/arm/include/asm/mach/time.h
===================================================================
--- gettimeoffset.orig/arch/arm/include/asm/mach/time.h	2009-12-22 18:50:54.000000000 -0800
+++ gettimeoffset/arch/arm/include/asm/mach/time.h	2009-12-22 18:51:20.000000000 -0800
@@ -50,7 +50,7 @@ extern void timer_tick(void);
  * Kernel time keeping support.
  */
 struct timespec;
-extern int (*set_rtc)(void);
+extern int (*set_rtc)(struct timespec now);
 extern void save_time_delta(struct timespec *delta, struct timespec *rtc);
 extern void restore_time_delta(struct timespec *delta, struct timespec *rtc);
 
Index: gettimeoffset/arch/arm/kernel/time.c
===================================================================
--- gettimeoffset.orig/arch/arm/kernel/time.c	2009-12-22 18:50:54.000000000 -0800
+++ gettimeoffset/arch/arm/kernel/time.c	2009-12-22 18:51:20.000000000 -0800
@@ -80,7 +80,7 @@ EXPORT_SYMBOL(profile_pc);
 /*
  * hook for setting the RTC's idea of the current time.
  */
-int (*set_rtc)(void);
+int (*set_rtc)(struct timespec now);
 
 #ifndef CONFIG_GENERIC_TIME
 static unsigned long dummy_gettimeoffset(void)
@@ -89,34 +89,11 @@ static unsigned long dummy_gettimeoffset
 }
 #endif
 
-static unsigned long next_rtc_update;
-
-/*
- * If we have an externally synchronized linux clock, then update
- * CMOS clock accordingly every ~11 minutes.  set_rtc() has to be
- * called as close as possible to 500 ms before the new second
- * starts.
- */
-static inline void do_set_rtc(void)
+int update_persistent_clock(struct timespec now)
 {
-	if (!ntp_synced() || set_rtc == NULL)
-		return;
-
-	if (next_rtc_update &&
-	    time_before((unsigned long)xtime.tv_sec, next_rtc_update))
-		return;
-
-	if (xtime.tv_nsec < 500000000 - ((unsigned) tick_nsec >> 1) &&
-	    xtime.tv_nsec >= 500000000 + ((unsigned) tick_nsec >> 1))
-		return;
-
-	if (set_rtc())
-		/*
-		 * rtc update failed.  Try again in 60s
-		 */
-		next_rtc_update = xtime.tv_sec + 60;
-	else
-		next_rtc_update = xtime.tv_sec + 660;
+	if (set_rtc == NULL)
+		return -1;
+	return set_rtc(now);
 }
 
 #ifdef CONFIG_LEDS
@@ -305,9 +282,10 @@ EXPORT_SYMBOL(do_settimeofday);
  */
 void save_time_delta(struct timespec *delta, struct timespec *rtc)
 {
+	struct timespec now = current_kernel_time();
 	set_normalized_timespec(delta,
-				xtime.tv_sec - rtc->tv_sec,
-				xtime.tv_nsec - rtc->tv_nsec);
+				now.tv_sec - rtc->tv_sec,
+				now.tv_nsec - rtc->tv_nsec);
 }
 EXPORT_SYMBOL(save_time_delta);
 
@@ -336,7 +314,6 @@ void timer_tick(void)
 {
 	profile_tick(CPU_PROFILING);
 	do_leds();
-	do_set_rtc();
 	write_seqlock(&xtime_lock);
 	do_timer(1);
 	write_sequnlock(&xtime_lock);
Index: gettimeoffset/arch/arm/mach-footbridge/time.c
===================================================================
--- gettimeoffset.orig/arch/arm/mach-footbridge/time.c	2009-12-22 18:50:54.000000000 -0800
+++ gettimeoffset/arch/arm/mach-footbridge/time.c	2009-12-22 18:51:20.000000000 -0800
@@ -61,12 +61,12 @@ static unsigned long __init get_isa_cmos
 	return mktime(year, mon, day, hour, min, sec);
 }
 
-static int set_isa_cmos_time(void)
+static int set_isa_cmos_time(struct timespec now)
 {
 	int retval = 0;
 	int real_seconds, real_minutes, cmos_minutes;
 	unsigned char save_control, save_freq_select;
-	unsigned long nowtime = xtime.tv_sec;
+	unsigned long nowtime = now.tv_sec;
 
 	save_control = CMOS_READ(RTC_CONTROL); /* tell the clock it's being set */
 	CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL);



  reply	other threads:[~2009-12-23  4:02 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-23  3:59 [RFC][PATCH 0/14] Convert remaining arches to read/update_persistent_clock john stultz
2009-12-23  4:00 ` [RFC][PATCH 1/14] Convert alpha " john stultz
2009-12-23  4:01   ` john stultz [this message]
2009-12-23  4:03     ` [RFC][PATCH 3/14] Convert avr32 " john stultz
2009-12-23  4:04       ` [RFC][PATCH 4/14] Convert blackfin " john stultz
2009-12-23  4:05         ` [RFC][PATCH 5/14] Convert cris " john stultz
2009-12-23  4:06           ` [RFC][PATCH 6/14] Convert frv " john stultz
2009-12-23  4:08             ` [RFC][PATCH 7/14] Convert h8300 " john stultz
2009-12-23  4:09               ` [RFC][PATCH 8/14] Convert ia64 " john stultz
2009-12-23  4:10                 ` [RFC][PATCH 9/14] Convert m32r " john stultz
2009-12-23  4:11                   ` [RFC][PATCH 10/14] Convert m68k " john stultz
2009-12-23  4:12                     ` [RFC][PATCH 11/14] Convert mn10300 " john stultz
2009-12-23  4:14                       ` [RFC][PATCH 12/14] Convert parisc " john stultz
2009-12-23  4:15                         ` [RFC][PATCH 13/14] Convert sh " john stultz
2009-12-23  4:16                           ` [RFC][PATCH 14/14] Convert sparc " john stultz
2009-12-24  4:52                             ` David Miller
2010-01-05 16:41                             ` Kristoffer Glembo
2010-01-05 17:08                       ` [RFC][PATCH 11/14] Convert mn10300 " David Howells
2010-01-05 16:47             ` [RFC][PATCH 6/14] Convert frv " David Howells
2009-12-24 11:09     ` [RFC][PATCH 2/14] Convert arm " Uwe Kleine-König
2009-12-23  5:08 ` [RFC][PATCH 0/14] Convert remaining arches " Paul Mundt
2009-12-23 10:08   ` Geert Uytterhoeven
2009-12-23 22:04   ` john stultz
2009-12-24  0:27     ` Dialup Jon Norstog
2009-12-24  4:54   ` David Miller
2009-12-24  5:10     ` Paul Mundt

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=1261540902.3508.63.camel@localhost.localdomain \
    --to=johnstul@us.ibm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    /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