0001
0002 #ifndef _LINUX_DELAY_H
0003 #define _LINUX_DELAY_H
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #include <linux/math.h>
0023 #include <linux/sched.h>
0024
0025 extern unsigned long loops_per_jiffy;
0026
0027 #include <asm/delay.h>
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039 #ifndef MAX_UDELAY_MS
0040 #define MAX_UDELAY_MS 5
0041 #endif
0042
0043 #ifndef mdelay
0044 #define mdelay(n) (\
0045 (__builtin_constant_p(n) && (n)<=MAX_UDELAY_MS) ? udelay((n)*1000) : \
0046 ({unsigned long __ms=(n); while (__ms--) udelay(1000);}))
0047 #endif
0048
0049 #ifndef ndelay
0050 static inline void ndelay(unsigned long x)
0051 {
0052 udelay(DIV_ROUND_UP(x, 1000));
0053 }
0054 #define ndelay(x) ndelay(x)
0055 #endif
0056
0057 extern unsigned long lpj_fine;
0058 void calibrate_delay(void);
0059 void __attribute__((weak)) calibration_delay_done(void);
0060 void msleep(unsigned int msecs);
0061 unsigned long msleep_interruptible(unsigned int msecs);
0062 void usleep_range_state(unsigned long min, unsigned long max,
0063 unsigned int state);
0064
0065 static inline void usleep_range(unsigned long min, unsigned long max)
0066 {
0067 usleep_range_state(min, max, TASK_UNINTERRUPTIBLE);
0068 }
0069
0070 static inline void usleep_idle_range(unsigned long min, unsigned long max)
0071 {
0072 usleep_range_state(min, max, TASK_IDLE);
0073 }
0074
0075 static inline void ssleep(unsigned int seconds)
0076 {
0077 msleep(seconds * 1000);
0078 }
0079
0080
0081 static inline void fsleep(unsigned long usecs)
0082 {
0083 if (usecs <= 10)
0084 udelay(usecs);
0085 else if (usecs <= 20000)
0086 usleep_range(usecs, 2 * usecs);
0087 else
0088 msleep(DIV_ROUND_UP(usecs, 1000));
0089 }
0090
0091 #endif