]> Git Repo - linux.git/commitdiff
ndelay(): switch to C function to avoid 64-bit division
authorAndrew Morton <[email protected]>
Tue, 4 Mar 2008 22:28:45 +0000 (14:28 -0800)
committerLinus Torvalds <[email protected]>
Wed, 5 Mar 2008 00:35:12 +0000 (16:35 -0800)
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.

[[email protected]: reported m68k build breakage]
Cc: Adrian Bunk <[email protected]>
Cc: Evgeniy Polyakov <[email protected]>
Cc: Martin Michlmayr <[email protected]>
Cc: Herbert Xu <[email protected]>
Cc: Ralf Baechle <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Adrian Bunk <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
include/linux/delay.h

index 17ddb55430ae19c28704a3da24f230b7a2e2ff6a..54552d21296efe9037de1d034ef45cafa4199067 100644 (file)
@@ -7,6 +7,8 @@
  * Delay routines, using a pre-computed "loops_per_jiffy" value.
  */
 
+#include <linux/kernel.h>
+
 extern unsigned long loops_per_jiffy;
 
 #include <asm/delay.h>
@@ -32,7 +34,11 @@ extern unsigned long loops_per_jiffy;
 #endif
 
 #ifndef ndelay
-#define ndelay(x)      udelay(((x)+999)/1000)
+static inline void ndelay(unsigned long x)
+{
+       udelay(DIV_ROUND_UP(x, 1000));
+}
+#define ndelay(x) ndelay(x)
 #endif
 
 void calibrate_delay(void);
This page took 0.055933 seconds and 4 git commands to generate.