]> git.sur5r.net Git - u-boot/commitdiff
ARM: Use do_div() instead of division for "long long".
authorSergei Poselenov <sposelenov@emcraft.com>
Thu, 14 Aug 2008 12:08:28 +0000 (14:08 +0200)
committerWolfgang Denk <wd@denx.de>
Tue, 9 Sep 2008 00:14:41 +0000 (02:14 +0200)
Signed-off-by: Sergei Poselenov <sposelenov@emcraft.com>
Signed-off-by: Wolfgang Denk <wd@denx.de>
board/integratorcp/integratorcp.c
board/trab/tsc2000.c
cpu/arm1176/s3c64xx/interrupts.c

index d6d6e13d5a475f20290bb86277affe17365522b8..220513f32947bfb492c2e8274b35d6d33242a52c 100644 (file)
@@ -34,6 +34,7 @@
  */
 
 #include <common.h>
+#include <div64.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -244,7 +245,11 @@ ulong get_timer_masked (void)
                total_count += lastdec - now;
        }
        lastdec   = now;
-       timestamp = (ulong)(total_count/div_timer);
+
+       /* Reuse "now" */
+       now = total_count;
+       do_div(now, div_timer);
+       timestamp = now;
 
        return timestamp;
 }
index 382a85b359300146d456f37f88c10dba6d5d5a40..f13a5a9dc0251d4173472381a1315e5fd448a9fd 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <common.h>
 #include <s3c2400.h>
+#include <div64.h>
 #include "tsc2000.h"
 
 #include "Pt1000_temp_data.h"
@@ -332,6 +333,7 @@ void tsc2000_reg_init (void)
 int tsc2000_interpolate(long value, long data[][2], long *result)
 {
        int i;
+       unsigned long long val;
 
        /* the data is sorted and the first element is upper
         * limit so we can easily check for out-of-band values
@@ -347,10 +349,10 @@ int tsc2000_interpolate(long value, long data[][2], long *result)
           result in 'long long'.
        */
 
-       *result = data[i-1][1] +
-               ((unsigned long long)(data[i][1] - data[i-1][1])
-                * (unsigned long long)(value - data[i-1][0]))
-               / (data[i][0] - data[i-1][0]);
+       val = ((unsigned long long)(data[i][1] - data[i-1][1])
+                  * (unsigned long long)(value - data[i-1][0]));
+       do_div(val, (data[i][0] - data[i-1][0]));
+       *result = data[i-1][1] + val;
 
        return 0;
 }
index 8356ae49e4364d07727a97f8b0d89d190bcf0f1e..e34369f890929f364c73908fe8952ad295a11350 100644 (file)
@@ -41,6 +41,7 @@
 #include <common.h>
 #include <asm/proc-armv/ptrace.h>
 #include <s3c6400.h>
+#include <div64.h>
 
 static ulong timer_load_val;
 
@@ -148,7 +149,9 @@ void reset_timer(void)
 
 ulong get_timer_masked(void)
 {
-       return get_ticks() / (timer_load_val / (100 * CFG_HZ));
+       unsigned long long res = get_ticks();
+       do_div (res, (timer_load_val / (100 * CFG_HZ)));
+       return res;
 }
 
 ulong get_timer(ulong base)