From: Matthias Kaehlcke Date: Tue, 23 Feb 2010 23:22:00 +0000 (+0100) Subject: ep93xx: Fix calculation of sys ticks in clk_to_systicks() X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=d9f505e3cddbb7afce26dcfe0fd19b207ee57c09;p=project%2Fbcm63xx%2Fu-boot.git ep93xx: Fix calculation of sys ticks in clk_to_systicks() 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 --- diff --git a/cpu/arm920t/ep93xx/timer.c b/cpu/arm920t/ep93xx/timer.c index 6d969d9302..98c759c8f0 100644 --- a/cpu/arm920t/ep93xx/timer.c +++ b/cpu/arm920t/ep93xx/timer.c @@ -31,6 +31,7 @@ #include #include #include +#include #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)