aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86_64/kernel/time.c
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2007-07-21 11:10:11 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-21 21:37:08 -0400
commitaf74522ab782c718783b9d85d6d53b8cbf0c7b17 (patch)
tree65cec57eee7aae24c2e931ee1000522c32321ba6 /arch/x86_64/kernel/time.c
parent55f93afd89fe6b9b9e12cfb2d3eb1a68e21f529e (diff)
x86_64: use generic cmos update
Use the generic cmos update function in kernel/time/ntp.c Cc: john stultz <johnstul@us.ibm.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Chris Wright <chrisw@sous-sol.org> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andi Kleen <ak@suse.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/x86_64/kernel/time.c')
-rw-r--r--arch/x86_64/kernel/time.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/arch/x86_64/kernel/time.c b/arch/x86_64/kernel/time.c
index 5405a69a1f72..d0e014e4d9c4 100644
--- a/arch/x86_64/kernel/time.c
+++ b/arch/x86_64/kernel/time.c
@@ -80,8 +80,9 @@ EXPORT_SYMBOL(profile_pc);
80 * sheet for details. 80 * sheet for details.
81 */ 81 */
82 82
83static void set_rtc_mmss(unsigned long nowtime) 83static int set_rtc_mmss(unsigned long nowtime)
84{ 84{
85 int retval = 0;
85 int real_seconds, real_minutes, cmos_minutes; 86 int real_seconds, real_minutes, cmos_minutes;
86 unsigned char control, freq_select; 87 unsigned char control, freq_select;
87 88
@@ -121,6 +122,7 @@ static void set_rtc_mmss(unsigned long nowtime)
121 if (abs(real_minutes - cmos_minutes) >= 30) { 122 if (abs(real_minutes - cmos_minutes) >= 30) {
122 printk(KERN_WARNING "time.c: can't update CMOS clock " 123 printk(KERN_WARNING "time.c: can't update CMOS clock "
123 "from %d to %d\n", cmos_minutes, real_minutes); 124 "from %d to %d\n", cmos_minutes, real_minutes);
125 retval = -1;
124 } else { 126 } else {
125 BIN_TO_BCD(real_seconds); 127 BIN_TO_BCD(real_seconds);
126 BIN_TO_BCD(real_minutes); 128 BIN_TO_BCD(real_minutes);
@@ -140,12 +142,17 @@ static void set_rtc_mmss(unsigned long nowtime)
140 CMOS_WRITE(freq_select, RTC_FREQ_SELECT); 142 CMOS_WRITE(freq_select, RTC_FREQ_SELECT);
141 143
142 spin_unlock(&rtc_lock); 144 spin_unlock(&rtc_lock);
145
146 return retval;
143} 147}
144 148
149int update_persistent_clock(struct timespec now)
150{
151 return set_rtc_mmss(now.tv_sec);
152}
145 153
146void main_timer_handler(void) 154void main_timer_handler(void)
147{ 155{
148 static unsigned long rtc_update = 0;
149/* 156/*
150 * Here we are in the timer irq handler. We have irqs locally disabled (so we 157 * Here we are in the timer irq handler. We have irqs locally disabled (so we
151 * don't need spin_lock_irqsave()) but we don't know if the timer_bh is running 158 * don't need spin_lock_irqsave()) but we don't know if the timer_bh is running
@@ -173,20 +180,6 @@ void main_timer_handler(void)
173 if (!using_apic_timer) 180 if (!using_apic_timer)
174 smp_local_timer_interrupt(); 181 smp_local_timer_interrupt();
175 182
176/*
177 * If we have an externally synchronized Linux clock, then update CMOS clock
178 * accordingly every ~11 minutes. set_rtc_mmss() will be called in the jiffy
179 * closest to exactly 500 ms before the next second. If the update fails, we
180 * don't care, as it'll be updated on the next turn, and the problem (time way
181 * off) isn't likely to go away much sooner anyway.
182 */
183
184 if (ntp_synced() && xtime.tv_sec > rtc_update &&
185 abs(xtime.tv_nsec - 500000000) <= tick_nsec / 2) {
186 set_rtc_mmss(xtime.tv_sec);
187 rtc_update = xtime.tv_sec + 660;
188 }
189
190 write_sequnlock(&xtime_lock); 183 write_sequnlock(&xtime_lock);
191} 184}
192 185