From: Jean-Christophe PLAGNIOL-VILLARD Date: Mon, 20 Oct 2008 13:21:28 +0200 Subject: [U-Boot] [PATCH][iMX31] Change to use "do_div" macro In-Reply-To: <48FC2DF1.6020300@tripeaks.co.jp> References: <48FC2DF1.6020300@tripeaks.co.jp> Message-ID: <20081020112128.GB20502@game.jcrosoft.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 > ---- > 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 > #include > +#include > > #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.