Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

openrisc: delay: fix loops calculation for __const_udelay

The openrisc implementation of __const_udelay casts the result of a
32-bit multiplication to 64 bits and passes the top 32 bits to __delay.
Since there are no casts on the arguments, this results in a __delay of
zero, regardless of the xloops parameter.

This patch fixes the problem by casting xloops to (unsigned long long),
ensuring that the multiplication is not truncated.

Cc: Jon Masters <jcm@redhat.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Jonas Bonn <jonas@southpole.se>

authored by

Will Deacon and committed by
Jonas Bonn
43916466 fea7a08a

+1 -1
+1 -1
arch/openrisc/lib/delay.c
··· 41 41 { 42 42 unsigned long long loops; 43 43 44 - loops = xloops * loops_per_jiffy * HZ; 44 + loops = (unsigned long long)xloops * loops_per_jiffy * HZ; 45 45 46 46 __delay(loops >> 32); 47 47 }