ARM: Use do_div() instead of division for "long long".

Signed-off-by: Sergei Poselenov <sposelenov@emcraft.com>
Signed-off-by: Wolfgang Denk <wd@denx.de>
This commit is contained in:
Sergei Poselenov 2008-08-14 14:08:28 +02:00 committed by Wolfgang Denk
parent 1055171ed0
commit 4265c35fbc
3 changed files with 16 additions and 6 deletions

View 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;
}

View 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;
}

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