[U-Boot] [PATCH][iMX31] Change to use "do_div" macro
Jean-Christophe PLAGNIOL-VILLARD
plagnioj at jcrosoft.com
Mon Oct 20 13:21:28 CEST 2008
On 16:06 Mon 20 Oct , Tomohiro Masubuchi wrote:
> I tryed to build u-boot by Sourcery G++ Lite 2008q3-41 for ARM GNU/Linux.
> But, it was failed with some link error of divide function.
> Thus, I changed to use the "do_div" macro to calculate the dividing.
>
> In my environment, the "next" branch with this patch worked correctly.
>
> Signed-off-by: Tomohiro Masubuchi <tomohiro_masubuchi at tripeaks.co.jp>
> ----
> Change to use the "do_div" macro.
>
> cpu/arm1136/mx31/interrupts.c | 36 ++++++++++++++++++++++++++++++------
> 1 files changed, 30 insertions(+), 6 deletions(-)
>
> diff --git a/cpu/arm1136/mx31/interrupts.c b/cpu/arm1136/mx31/interrupts.c
> index b36c58c..807e791 100644
> --- a/cpu/arm1136/mx31/interrupts.c
> +++ b/cpu/arm1136/mx31/interrupts.c
> @@ -23,6 +23,7 @@
>
> #include <common.h>
> #include <asm/arch/mx31-regs.h>
> +#include <div64.h>
>
> #define TIMER_BASE 0x53f90000 /* General purpose timer 1 */
>
> @@ -41,17 +42,40 @@
> /* "time" is measured in 1 / CONFIG_SYS_HZ seconds, "tick" is internal timer period */
> #ifdef CONFIG_MX31_TIMER_HIGH_PRECISION
> /* ~0.4% error - measured with stop-watch on 100s boot-delay */
> -#define TICK_TO_TIME(t) ((t) * CONFIG_SYS_HZ / CONFIG_MX31_CLK32)
> -#define TIME_TO_TICK(t) ((unsigned long long)(t) * CONFIG_MX31_CLK32 / CONFIG_SYS_HZ)
> -#define US_TO_TICK(t) (((unsigned long long)(t) * CONFIG_MX31_CLK32 + \
> - 999999) / 1000000)
> +#define TICK_TO_TIME(t) ({ \
> + unsigned long long tmp = (t); \
> + t *= CONFIG_SYS_HZ; \
> + do_div(tmp, CONFIG_MX31_CLK32); \
> + tmp; \
> + })
IMHO implement it as inline will be better : simple to maintain and to read
Best Regards,
J.
More information about the U-Boot
mailing list