[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 <jbeulich@novell.com>

Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by Jan Beulich and committed by Linus Torvalds 5329e13d bdf2b1c9

+4 -7
+4 -7
arch/x86_64/kernel/time.c
··· 504 505 static unsigned long get_cmos_time(void) 506 { 507 - unsigned int timeout, year, mon, day, hour, min, sec; 508 - unsigned char last, this; 509 unsigned long flags; 510 511 /* ··· 518 519 spin_lock_irqsave(&rtc_lock, flags); 520 521 - timeout = 1000000; 522 - last = this = 0; 523 - 524 - while (timeout && last && !this) { 525 - last = this; 526 this = CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP; 527 timeout--; 528 }
··· 504 505 static unsigned long get_cmos_time(void) 506 { 507 + unsigned int timeout = 1000000, year, mon, day, hour, min, sec; 508 + unsigned char uip = 0, this = 0; 509 unsigned long flags; 510 511 /* ··· 518 519 spin_lock_irqsave(&rtc_lock, flags); 520 521 + while (timeout && (!uip || this)) { 522 + uip |= this; 523 this = CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP; 524 timeout--; 525 }