From: Andrew Morton <akpm@osdl.org>

Dopey div-by-zero workaround for HPET fallback.

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

Cc: Robert Picco <Robert.Picco@hp.com>
Cc: "Pallipadi, Venkatesh" <venkatesh.pallipadi@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 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-07 20:10:36.000000000 -0700
+++ devel-akpm/arch/x86_64/kernel/time.c	2005-09-07 20:10:36.000000000 -0700
@@ -76,6 +76,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
@@ -305,7 +310,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 {
@@ -400,11 +405,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
_