Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / include / linux / delay.h
1 #ifndef _LINUX_DELAY_H
2 #define _LINUX_DELAY_H
3
4 /*
5  * Copyright (C) 1993 Linus Torvalds
6  *
7  * Delay routines, using a pre-computed "loops_per_jiffy" value.
8  */
9
10 extern unsigned long loops_per_jiffy;
11
12 #include <asm/delay.h>
13 #include <linux/hardirq.h>
14 /*
15  * Using udelay() for intervals greater than a few milliseconds can
16  * risk overflow for high loops_per_jiffy (high bogomips) machines. The
17  * mdelay() provides a wrapper to prevent this.  For delays greater
18  * than MAX_UDELAY_MS milliseconds, the wrapper is used.  Architecture
19  * specific values can be defined in asm-???/delay.h as an override.
20  * The 2nd mdelay() definition ensures GCC will optimize away the 
21  * while loop for the common cases where n <= MAX_UDELAY_MS  --  Paul G.
22  */
23
24 #ifndef MAX_UDELAY_MS
25 #define MAX_UDELAY_MS   5
26 #endif
27
28 #define mdelay(n) (                                     \
29         {                                               \
30                 static int warned=0;                    \
31                 unsigned long __ms=(n);                 \
32                 WARN_ON(in_irq() && !(warned++));       \
33                 while (__ms--) udelay(1000);            \
34         })
35
36 #ifndef ndelay
37 #define ndelay(x)       udelay(((x)+999)/1000)
38 #endif
39
40 void calibrate_delay(void);
41 void msleep(unsigned int msecs);
42 unsigned long msleep_interruptible(unsigned int msecs);
43
44 static inline void ssleep(unsigned int seconds)
45 {
46         msleep(seconds * 1000);
47 }
48
49 #endif /* defined(_LINUX_DELAY_H) */