ARM: Use do_div() instead of division for "long long".
PATCH 1/1 ARM: Use do_div() instead of division for "long long".
From: Sergei Poselenov <[email protected]>
Also make sure to feed the right compiler options.
---
These changes are needed with some more recent tool chain versions (including ELDK 4.2).
board/integratorcp/integratorcp.c | 7 ++++++- board/trab/tsc2000.c | 10 ++++++---- cpu/arm1176/s3c64xx/interrupts.c | 5 ++++- cpu/arm946es/config.mk | 7 +++++++ cpu/arm_intcm/config.mk | 7 +++++++ 5 files changed, 30 insertions(+), 6 deletions(-)
board/integratorcp/integratorcp.c +6 -1
@@ -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; }
board/trab/tsc2000.c +6 -4
@@ -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 ; }
cpu/arm1176/s3c64xx/interrupts.c +4 -1
@@ -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)
cpu/arm946es/config.mk +7 -0
@@ -25,3 +25,10 @@ PLATFORM_RELFLAGS += -fno-strict-aliasing -fno-common -ffixed-r8 \ -msoft-float PLATFORM_CPPFLAGS += -march=armv4 +# ========================================================================= +# +# Supply options according to compiler version +# +# ========================================================================= +PLATFORM_CPPFLAGS +=$(call cc-option,-mapcs-32,-mabi=apcs-gnu) +PLATFORM_RELFLAGS +=$(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,))
cpu/arm_intcm/config.mk +7 -0
@@ -25,3 +25,10 @@ PLATFORM_RELFLAGS += -fno-strict-aliasing -fno-common -ffixed-r8 \ -msoft-float PLATFORM_CPPFLAGS += -march=armv4 +# ========================================================================= +# +# Supply options according to compiler version +# +# ========================================================================= +PLATFORM_CPPFLAGS +=$(call cc-option,-mapcs-32,-mabi=apcs-gnu) +PLATFORM_RELFLAGS +=$(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,))
Signature · 1 line
1.5.5.1
PATCH 1/1 ARM: Use do_div() instead of division for "long long".
Quoted 7 lines
#include <
asm/proc-armv/ptrace.h>
#include <s3c6400.h>cpu/arm1176/s3c64xx/interrupts.c +1
-0+#include <div64.h> static ulong timer_load_val;
cpu/arm1176/s3c64xx/interrupts.c void reset_timer(void) · line 154
Quoted 7 lines
cpu/arm1176/s3c64xx/interrupts.c +3
-1@@ -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;
CFG_HZ was renamed CONFIG_SYS_HZ
Review void reset_timer(void) · line 155
Quoted 1 line
(quoted diff) +0
-0}
I've start to think to re-rename it CFG_HZ as done in Linux, normaly this value is the same for all arch & board
Best Regards,
J.
PATCH 1/1 ARM: Use do_div() instead of division for "long long".
Dear Jean-Christophe PLAGNIOL-VILLARD,
Quoted 1 line · In message <[email protected]> you wrote:
...
Quoted 1 line
CFG_HZwas renamedCONFIG_SYS_HZ
...
Quoted 2 lines
I've start to think to re-rename it
CFG_HZas done in Linux, normaly this value is the same for all arch & board
Mind that there is a slight difference in meaning and a bigger one in implementation.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Anyone who doesn't believe in miracles is not a realist.
- David Ben GurionPATCH 1/1 ARM: Use do_div() instead of division for "long long".
In reply to Wolfgang DenkQuoted 10 lines · Wolfgang Denk
From: Sergei Poselenov <[email protected]>
Also make sure to feed the right compiler options.
Signed-off-by Sergei Poselenov <[email protected]>Signed-off-by Wolfgang Denk <[email protected]>---
These changes are needed with some more recent tool chain versions (including ELDK 4.2).
Quoted 6 lines
board/integratorcp/integratorcp.c | 7 ++++++- board/trab/tsc2000.c | 10 ++++++---- cpu/arm1176/s3c64xx/interrupts.c | 5 ++++- cpu/arm946es/config.mk | 7 +++++++ cpu/arm_intcm/config.mk | 7 +++++++ 5 files changed, 30 insertions(+), 6 deletions(-)
do you have any plan to rebase it?
Best Regards,
J.