diff options
author | Quinn Jensen <quinn.jensen@freescale.com> | 2007-05-24 18:12:40 -0600 |
---|---|---|
committer | Quinn Jensen <quinn.jensen@freescale.com> | 2007-05-24 18:12:40 -0600 |
commit | 03d9725c6eef45a4c8cb5feee49f01044ff7f1df (patch) | |
tree | 285b8988bdd611aafb721e30304b4dd62fe81c48 | |
parent | af0e647babe79fe0c093644056c9b774b64d45ab (diff) |
CR ENGR00018343: Fix divide-by-zero error in mxc_gettimeoffset().
http://www.bitshrine.org/gpp/linux-2.6.19.2-mx-fix_mxc_gettimeoffset_div0.patch
-rw-r--r-- | arch/arm/mach-mx27/time.c | 10 | ||||
-rw-r--r-- | arch/arm/mach-mx3/time.c | 10 |
2 files changed, 4 insertions, 16 deletions
diff --git a/arch/arm/mach-mx27/time.c b/arch/arm/mach-mx27/time.c index 2e9628c8536c..557824278506 100644 --- a/arch/arm/mach-mx27/time.c +++ b/arch/arm/mach-mx27/time.c @@ -93,7 +93,7 @@ static irqreturn_t mxc_timer_interrupt(int irq, void *dev_id) */ static unsigned long __noinstrument mxc_gettimeoffset(void) { - unsigned long ticks_to_match, elapsed, usec, tick_usec, i; + long ticks_to_match, elapsed, usec; /* Get ticks before next timer match */ ticks_to_match = @@ -103,13 +103,7 @@ static unsigned long __noinstrument mxc_gettimeoffset(void) elapsed = LATCH - ticks_to_match; /* Now convert them to usec */ - /* Insure no overflow when calculating the usec below */ - for (i = 1, tick_usec = tick_nsec / 1000;; i *= 2) { - tick_usec /= i; - if ((0xFFFFFFFF / tick_usec) > elapsed) - break; - } - usec = (unsigned long)(elapsed * tick_usec) / (LATCH / i); + usec = (unsigned long)(elapsed * (tick_nsec / 1000)) / LATCH; return usec; } diff --git a/arch/arm/mach-mx3/time.c b/arch/arm/mach-mx3/time.c index 554d4c679e1f..730046033339 100644 --- a/arch/arm/mach-mx3/time.c +++ b/arch/arm/mach-mx3/time.c @@ -155,7 +155,7 @@ static irqreturn_t mxc_timer_interrupt(int irq, void *dev_id) */ static unsigned long __noinstrument mxc_gettimeoffset(void) { - unsigned long ticks_to_match, elapsed, usec, tick_usec, i; + long ticks_to_match, elapsed, usec; /* Get ticks before next timer match */ ticks_to_match = @@ -165,13 +165,7 @@ static unsigned long __noinstrument mxc_gettimeoffset(void) elapsed = LATCH - ticks_to_match; /* Now convert them to usec */ - /* Insure no overflow when calculating the usec below */ - for (i = 1, tick_usec = tick_nsec / 1000;; i *= 2) { - tick_usec /= i; - if ((0xFFFFFFFF / tick_usec) > elapsed) - break; - } - usec = (unsigned long)(elapsed * tick_usec) / (LATCH / i); + usec = (unsigned long)(elapsed * (tick_nsec / 1000)) / LATCH; return usec; } |