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/i386/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/i386/kernel/time.c')
-rw-r--r-- | arch/i386/kernel/time.c | 50 |
1 files changed, 2 insertions, 48 deletions
diff --git a/arch/i386/kernel/time.c b/arch/i386/kernel/time.c index a665df61f08..19a6c678d02 100644 --- a/arch/i386/kernel/time.c +++ b/arch/i386/kernel/time.c | |||
@@ -207,55 +207,9 @@ unsigned long read_persistent_clock(void) | |||
207 | return retval; | 207 | return retval; |
208 | } | 208 | } |
209 | 209 | ||
210 | static void sync_cmos_clock(unsigned long dummy); | 210 | int update_persistent_clock(struct timespec now) |
211 | |||
212 | static DEFINE_TIMER(sync_cmos_timer, sync_cmos_clock, 0, 0); | ||
213 | int no_sync_cmos_clock; | ||
214 | |||
215 | static void sync_cmos_clock(unsigned long dummy) | ||
216 | { | ||
217 | struct timeval now, next; | ||
218 | int fail = 1; | ||
219 | |||
220 | /* | ||
221 | * If we have an externally synchronized Linux clock, then update | ||
222 | * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be | ||
223 | * called as close as possible to 500 ms before the new second starts. | ||
224 | * This code is run on a timer. If the clock is set, that timer | ||
225 | * may not expire at the correct time. Thus, we adjust... | ||
226 | */ | ||
227 | if (!ntp_synced()) | ||
228 | /* | ||
229 | * Not synced, exit, do not restart a timer (if one is | ||
230 | * running, let it run out). | ||
231 | */ | ||
232 | return; | ||
233 | |||
234 | do_gettimeofday(&now); | ||
235 | if (now.tv_usec >= USEC_AFTER - ((unsigned) TICK_SIZE) / 2 && | ||
236 | now.tv_usec <= USEC_BEFORE + ((unsigned) TICK_SIZE) / 2) | ||
237 | fail = set_rtc_mmss(now.tv_sec); | ||
238 | |||
239 | next.tv_usec = USEC_AFTER - now.tv_usec; | ||
240 | if (next.tv_usec <= 0) | ||
241 | next.tv_usec += USEC_PER_SEC; | ||
242 | |||
243 | if (!fail) | ||
244 | next.tv_sec = 659; | ||
245 | else | ||
246 | next.tv_sec = 0; | ||
247 | |||
248 | if (next.tv_usec >= USEC_PER_SEC) { | ||
249 | next.tv_sec++; | ||
250 | next.tv_usec -= USEC_PER_SEC; | ||
251 | } | ||
252 | mod_timer(&sync_cmos_timer, jiffies + timeval_to_jiffies(&next)); | ||
253 | } | ||
254 | |||
255 | void notify_arch_cmos_timer(void) | ||
256 | { | 211 | { |
257 | if (!no_sync_cmos_clock) | 212 | return set_rtc_mmss(now.tv_sec); |
258 | mod_timer(&sync_cmos_timer, jiffies + 1); | ||
259 | } | 213 | } |
260 | 214 | ||
261 | extern void (*late_time_init)(void); | 215 | extern void (*late_time_init)(void); |