[U-Boot] [PATCH 4/4] ARM: bcm283x: Switch to generic timer

Stephen Warren swarren at wwwdotorg.org
Tue May 5 23:46:56 CEST 2015


On 05/04/2015 02:54 PM, Marek Vasut wrote:
> Switch to generic timer implementation from lib/time.c .
> This also fixes a signed overflow which was in __udelay()
> implementation.

Can you explain that a bit more?

> -void __udelay(unsigned long usec)
> -{
> -	ulong endtime;
> -	signed long diff;
> -
> -	endtime = get_timer_us(0) + usec;
> -
> -	do {
> -		ulong now = get_timer_us(0);
> -		diff = endtime - now;
> -	} while (diff >= 0);
> -}

I believe since endtime and now hold micro seconds, there shouldn't be 
any overflow so long as the microsecond difference fits into 31 bits, 
i.e. so long as usec is less than ~36 minutes. I doubt anything is 
calling __udelay() with that large of a value. Perhaps the issue this 
patch fixes is in get_timer_us(0) instead, or something else changed as 
a side-effect?

The other 3 patches in this series,
Acked-by: Stephen Warren <swarren at wwwdotorg.org>


More information about the U-Boot mailing list