Commit 5cba6d22e35a05adb28fdea191b232501518c455

Authored by Andrew Morton
Committed by Linus Torvalds
1 parent daa49ff50a

ndelay(): switch to C function to avoid 64-bit division

We should be able to do ndelay(some_u64), but that can cause a call to
__divdi3() to be emitted because the ndelay() macros does a divide.

Fix it by switching to static inline which will force the u64 arg to be
treated as an unsigned long.  udelay() takes an unsigned long arg.

[bunk@kernel.org: reported m68k build breakage]
Cc: Adrian Bunk <bunk@kernel.org>
Cc: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Cc: Martin Michlmayr <tbm@cyrius.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Adrian Bunk <bunk@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 7 additions and 1 deletions Side-by-side Diff

include/linux/delay.h
... ... @@ -7,6 +7,8 @@
7 7 * Delay routines, using a pre-computed "loops_per_jiffy" value.
8 8 */
9 9  
  10 +#include <linux/kernel.h>
  11 +
10 12 extern unsigned long loops_per_jiffy;
11 13  
12 14 #include <asm/delay.h>
... ... @@ -32,7 +34,11 @@
32 34 #endif
33 35  
34 36 #ifndef ndelay
35   -#define ndelay(x) udelay(((x)+999)/1000)
  37 +static inline void ndelay(unsigned long x)
  38 +{
  39 + udelay(DIV_ROUND_UP(x, 1000));
  40 +}
  41 +#define ndelay(x) ndelay(x)
36 42 #endif
37 43  
38 44 void calibrate_delay(void);