blob: 17ddb55430ae19c28704a3da24f230b7a2e2ff6a [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#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
10extern unsigned long loops_per_jiffy;
11
12#include <asm/delay.h>
13
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
Anton Blanchard1e92a552006-06-15 14:11:22 +100028#ifndef mdelay
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#define mdelay(n) (\
30 (__builtin_constant_p(n) && (n)<=MAX_UDELAY_MS) ? udelay((n)*1000) : \
31 ({unsigned long __ms=(n); while (__ms--) udelay(1000);}))
32#endif
33
34#ifndef ndelay
35#define ndelay(x) udelay(((x)+999)/1000)
36#endif
37
38void calibrate_delay(void);
39void msleep(unsigned int msecs);
40unsigned long msleep_interruptible(unsigned int msecs);
41
42static inline void ssleep(unsigned int seconds)
43{
44 msleep(seconds * 1000);
45}
46
47#endif /* defined(_LINUX_DELAY_H) */