From: Andrew Morton <[email-masked]>

Dopey div-by-zero workaround for HPET fallback.

http://lkml.org/lkml/2005/6/8/34

Cc: Robert Picco <[email-masked]>
Cc: "Pallipadi, Venkatesh" <[email-masked]>
Signed-off-by: Andrew Morton <[email-masked]>
---

 arch/x86_64/kernel/time.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff -puN arch/x86_64/kernel/time.c~x86_64-div-by-zero-fix arch/x86_64/kernel/time.c
--- devel/arch/x86_64/kernel/time.c~x86_64-div-by-zero-fix	2005-09-12 03:34:31.000000000 -0700
+++ devel-akpm/arch/x86_64/kernel/time.c	2005-09-12 03:34:31.000000000 -0700
@@ -75,6 +75,11 @@ unsigned long __wall_jiffies __section_w
 struct timespec __xtime __section_xtime;
 struct timezone __sys_tz __section_sys_tz;
 
+static inline unsigned long fixed_hpet_tick(void)
+{
+	return hpet_tick ? hpet_tick : 1;
+}
+
 static inline void rdtscll_sync(unsigned long *tsc)
 {
 #ifdef CONFIG_SMP
@@ -304,7 +309,7 @@ unsigned long long monotonic_clock(void)
 
 		} while (read_seqretry(&xtime_lock, seq));
 		offset = (this_offset - last_offset);
-		offset *=(NSEC_PER_SEC/HZ)/hpet_tick;
+		offset *=(NSEC_PER_SEC/HZ)/fixed_hpet_tick();
 		return base + offset;
 	}else{
 		do {
@@ -399,11 +404,11 @@ static irqreturn_t timer_interrupt(int i
 
 	if (vxtime.mode == VXTIME_HPET) {
 		if (offset - vxtime.last > hpet_tick) {
-			lost = (offset - vxtime.last) / hpet_tick - 1;
+			lost = (offset - vxtime.last) / fixed_hpet_tick() - 1;
 		}
 
-		monotonic_base += 
-			(offset - vxtime.last)*(NSEC_PER_SEC/HZ) / hpet_tick;
+		monotonic_base +=  (offset - vxtime.last)*(NSEC_PER_SEC/HZ) /
+					fixed_hpet_tick();
 
 		vxtime.last = offset;
 #ifdef CONFIG_X86_PM_TIMER
_