]> git.sur5r.net Git - u-boot/commitdiff
ep93xx: Fix calculation of sys ticks in clk_to_systicks()
authorMatthias Kaehlcke <matthias@kaehlcke.net>
Tue, 23 Feb 2010 23:22:00 +0000 (00:22 +0100)
committerTom Rix <Tom.Rix@windriver.com>
Sun, 7 Mar 2010 18:36:35 +0000 (12:36 -0600)
ep93xx: Use unsigned long long for calculation of sys ticks in clk_to_systicks()
for proper handling of large intermediate values

Signed-off-by: Matthias Kaehlcke <matthias@kaehlcke.net>
cpu/arm920t/ep93xx/timer.c

index 6d969d9302d8e5bc9349a3e725476d67187951c6..98c759c8f0a5ba3b4e5f43996ee8c86e3249f5af 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/types.h>
 #include <asm/arch/ep93xx.h>
 #include <asm/io.h>
+#include <div64.h>
 
 #define TIMER_CLKSEL   (1 << 3)
 #define TIMER_MODE     (1 << 6)
@@ -44,9 +45,10 @@ static ulong lastdec;
 
 static inline unsigned long clk_to_systicks(unsigned long clk_ticks)
 {
-       unsigned long sys_ticks = (clk_ticks * CONFIG_SYS_HZ) / TIMER_FREQ;
+       unsigned long long sys_ticks = (clk_ticks * CONFIG_SYS_HZ);
+       do_div(sys_ticks, TIMER_FREQ);
 
-       return sys_ticks;
+       return (unsigned long)sys_ticks;
 }
 
 static inline unsigned long usecs_to_ticks(unsigned long usecs)