From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matthias Kaehlcke Date: Wed, 24 Feb 2010 00:22:00 +0100 Subject: [U-Boot] [PATCH 1/2] ep93xx: Fix calculation of sys ticks in clk_to_systicks() Message-ID: <20100223232200.GQ20201@darwin> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 --- cpu/arm920t/ep93xx/timer.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cpu/arm920t/ep93xx/timer.c b/cpu/arm920t/ep93xx/timer.c index 6d969d9..98c759c 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) -- 1.6.5