From: Jan Beulich Date: Wed, 11 Jan 2006 21:46:42 +0000 (+0100) Subject: [PATCH] x86_64: Fix get_cmos_time() X-Git-Tag: v2.6.16-rc1~294 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=5329e13d0bd82e13814050eb9facb25eedde4bbc;p=linux-2.6-omap-h63xx.git [PATCH] x86_64: Fix get_cmos_time() Due to a broken condition, the body of the loop that is intended to wait for the Update-In-Progress bit to get set and then cleared again was never entered; in fact, the entire loop was optimized out by the compiler. Here is a change to fix the condition (and to also move the initialization of locals out of the spin lock protected region). Signed-Off-By: Jan Beulich Signed-off-by: Andi Kleen Signed-off-by: Linus Torvalds --- diff --git a/arch/x86_64/kernel/time.c b/arch/x86_64/kernel/time.c index 966d1376b59..f8c47c68844 100644 --- a/arch/x86_64/kernel/time.c +++ b/arch/x86_64/kernel/time.c @@ -504,8 +504,8 @@ unsigned long long sched_clock(void) static unsigned long get_cmos_time(void) { - unsigned int timeout, year, mon, day, hour, min, sec; - unsigned char last, this; + unsigned int timeout = 1000000, year, mon, day, hour, min, sec; + unsigned char uip = 0, this = 0; unsigned long flags; /* @@ -518,11 +518,8 @@ static unsigned long get_cmos_time(void) spin_lock_irqsave(&rtc_lock, flags); - timeout = 1000000; - last = this = 0; - - while (timeout && last && !this) { - last = this; + while (timeout && (!uip || this)) { + uip |= this; this = CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP; timeout--; }