public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Matthias Kaehlcke <matthias@kaehlcke.net>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/2] ep93xx: Fix calculation of sys ticks in clk_to_systicks()
Date: Tue, 23 Feb 2010 23:04:00 +0100	[thread overview]
Message-ID: <20100223220400.GJ20201@darwin> (raw)

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

             reply	other threads:[~2010-02-23 22:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-23 22:04 Matthias Kaehlcke [this message]
  -- strict thread matches above, loose matches on Subject: below --
2010-02-23 23:22 [U-Boot] [PATCH 1/2] ep93xx: Fix calculation of sys ticks in clk_to_systicks() Matthias Kaehlcke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100223220400.GJ20201@darwin \
    --to=matthias@kaehlcke.net \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox