5 * Copyright (C) 1993 Linus Torvalds
7 * Delay routines, using a pre-computed "loops_per_jiffy" value.
10 extern unsigned long loops_per_jiffy;
12 #include <asm/delay.h>
13 #include <linux/hardirq.h>
16 * Using udelay() for intervals greater than a few milliseconds can
17 * risk overflow for high loops_per_jiffy (high bogomips) machines. The
18 * mdelay() provides a wrapper to prevent this. For delays greater
19 * than MAX_UDELAY_MS milliseconds, the wrapper is used. Architecture
20 * specific values can be defined in asm-???/delay.h as an override.
21 * The 2nd mdelay() definition ensures GCC will optimize away the
22 * while loop for the common cases where n <= MAX_UDELAY_MS -- Paul G.
26 #define MAX_UDELAY_MS 5
30 #ifdef CONFIG_DEBUG_SLEEP_IN_IRQ
33 static int warned=0; \
34 unsigned long __ms=(n); \
35 WARN_ON(in_irq() && !(warned++)); \
36 while (__ms--) udelay(1000); \
40 (__builtin_constant_p(n) && (n)<=MAX_UDELAY_MS) ? udelay((n)*1000) : \
41 ({unsigned long __ms=(n); while (__ms--) udelay(1000);}))
46 #define ndelay(x) udelay(((x)+999)/1000)
49 void calibrate_delay(void);
50 void msleep(unsigned int msecs);
51 unsigned long msleep_interruptible(unsigned int msecs);
53 static inline void ssleep(unsigned int seconds)
55 msleep(seconds * 1000);
58 #endif /* defined(_LINUX_DELAY_H) */