lkml.org 
[lkml]   [2013]   [Aug]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] ARC: Fix __udelay parentheses
From
Date
On Wed, 2013-08-28 at 20:29 +0200, Mischa Jonker wrote:
> Make sure that usecs is casted to long long, to ensure that the
> (usecs * 4295 * HZ) multiplication is 64 bit.
>
> Initially, the (usecs * 4295 * HZ) part was done as a 32 bit
> multiplication, with the result casted to 64 bit. This led to some bits
> falling off.
>
> Signed-off-by: Mischa Jonker <mjonker@synopsys.com>
> ---
> arch/arc/include/asm/delay.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arc/include/asm/delay.h b/arch/arc/include/asm/delay.h
> index 442ce5d..8d35fe1 100644
> --- a/arch/arc/include/asm/delay.h
> +++ b/arch/arc/include/asm/delay.h
> @@ -56,8 +56,8 @@ static inline void __udelay(unsigned long usecs)
> /* (long long) cast ensures 64 bit MPY - real or emulated
> * HZ * 4295 is pre-evaluated by gcc - hence only 2 mpy ops
> */
> - loops = ((long long)(usecs * 4295 * HZ) *
> - (long long)(loops_per_jiffy)) >> 32;
> + loops = (((long long) usecs) * 4295 * HZ *
> + (long long) loops_per_jiffy) >> 32;

Shouldn't this be unsigned long long or u64?

Why is it >> 32 again?

The comment above it doesn't seem to match the code.




\
 
 \ /
  Last update: 2013-08-28 21:21    [W:1.184 / U:1.280 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site