diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2007-07-21 07:37:37 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-21 20:49:15 -0400 |
commit | 82644459c592a28a3eab682f9b88d81019ddfe8b (patch) | |
tree | 738e4edaf54658912e78a8bcdadc3e2165ecb77a /arch/sparc64/kernel/time.c | |
parent | 99bc2fcb283852931fb6bbef40f3df8316b59000 (diff) |
NTP: move the cmos update code into ntp.c
i386 and sparc64 have the identical code to update the cmos clock. Move it
into kernel/time/ntp.c as there are other architectures coming along with the
same requirements.
[akpm@linux-foundation.org: build fixes]
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Chris Wright <chrisw@sous-sol.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: john stultz <johnstul@us.ibm.com>
Cc: David Miller <davem@davemloft.net>
Cc: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/sparc64/kernel/time.c')
-rw-r--r-- | arch/sparc64/kernel/time.c | 53 |
1 files changed, 2 insertions, 51 deletions
diff --git a/arch/sparc64/kernel/time.c b/arch/sparc64/kernel/time.c index 87c10a7544da..49063ca2efcd 100644 --- a/arch/sparc64/kernel/time.c +++ b/arch/sparc64/kernel/time.c | |||
@@ -403,58 +403,9 @@ static struct sparc64_tick_ops hbtick_operations __read_mostly = { | |||
403 | 403 | ||
404 | static unsigned long timer_ticks_per_nsec_quotient __read_mostly; | 404 | static unsigned long timer_ticks_per_nsec_quotient __read_mostly; |
405 | 405 | ||
406 | #define TICK_SIZE (tick_nsec / 1000) | 406 | int update_persistent_clock(struct timespec now) |
407 | |||
408 | #define USEC_AFTER 500000 | ||
409 | #define USEC_BEFORE 500000 | ||
410 | |||
411 | static void sync_cmos_clock(unsigned long dummy); | ||
412 | |||
413 | static DEFINE_TIMER(sync_cmos_timer, sync_cmos_clock, 0, 0); | ||
414 | |||
415 | static void sync_cmos_clock(unsigned long dummy) | ||
416 | { | ||
417 | struct timeval now, next; | ||
418 | int fail = 1; | ||
419 | |||
420 | /* | ||
421 | * If we have an externally synchronized Linux clock, then update | ||
422 | * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be | ||
423 | * called as close as possible to 500 ms before the new second starts. | ||
424 | * This code is run on a timer. If the clock is set, that timer | ||
425 | * may not expire at the correct time. Thus, we adjust... | ||
426 | */ | ||
427 | if (!ntp_synced()) | ||
428 | /* | ||
429 | * Not synced, exit, do not restart a timer (if one is | ||
430 | * running, let it run out). | ||
431 | */ | ||
432 | return; | ||
433 | |||
434 | do_gettimeofday(&now); | ||
435 | if (now.tv_usec >= USEC_AFTER - ((unsigned) TICK_SIZE) / 2 && | ||
436 | now.tv_usec <= USEC_BEFORE + ((unsigned) TICK_SIZE) / 2) | ||
437 | fail = set_rtc_mmss(now.tv_sec); | ||
438 | |||
439 | next.tv_usec = USEC_AFTER - now.tv_usec; | ||
440 | if (next.tv_usec <= 0) | ||
441 | next.tv_usec += USEC_PER_SEC; | ||
442 | |||
443 | if (!fail) | ||
444 | next.tv_sec = 659; | ||
445 | else | ||
446 | next.tv_sec = 0; | ||
447 | |||
448 | if (next.tv_usec >= USEC_PER_SEC) { | ||
449 | next.tv_sec++; | ||
450 | next.tv_usec -= USEC_PER_SEC; | ||
451 | } | ||
452 | mod_timer(&sync_cmos_timer, jiffies + timeval_to_jiffies(&next)); | ||
453 | } | ||
454 | |||
455 | void notify_arch_cmos_timer(void) | ||
456 | { | 407 | { |
457 | mod_timer(&sync_cmos_timer, jiffies + 1); | 408 | return set_rtc_mmss(now.tv_sec); |
458 | } | 409 | } |
459 | 410 | ||
460 | /* Kick start a stopped clock (procedure from the Sun NVRAM/hostid FAQ). */ | 411 | /* Kick start a stopped clock (procedure from the Sun NVRAM/hostid FAQ). */ |