public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] ep93xx: Fix calculation of sys ticks in clk_to_systicks()
@ 2010-02-23 22:04 Matthias Kaehlcke
  0 siblings, 0 replies; 2+ messages in thread
From: Matthias Kaehlcke @ 2010-02-23 22:04 UTC (permalink / raw)
  To: u-boot

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 |    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 <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)
-- 
1.6.5

^ permalink raw reply related	[flat|nested] 2+ messages in thread
* [U-Boot] [PATCH 1/2] ep93xx: Fix calculation of sys ticks in clk_to_systicks()
@ 2010-02-23 23:22 Matthias Kaehlcke
  0 siblings, 0 replies; 2+ messages in thread
From: Matthias Kaehlcke @ 2010-02-23 23:22 UTC (permalink / raw)
  To: u-boot

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 |    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 <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)
-- 
1.6.5

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-02-23 23:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-23 22:04 [U-Boot] [PATCH 1/2] ep93xx: Fix calculation of sys ticks in clk_to_systicks() Matthias Kaehlcke
  -- strict thread matches above, loose matches on Subject: below --
2010-02-23 23:22 Matthias Kaehlcke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox