xref: /openbsd/sys/dev/pci/drm/include/linux/delay.h (revision 5dea098c)
1 /* Public domain. */
2 
3 #ifndef _LINUX_DELAY_H
4 #define _LINUX_DELAY_H
5 
6 #include <sys/param.h>
7 #include <sys/systm.h>
8 
9 static inline void
10 udelay(unsigned long usecs)
11 {
12 	DELAY(usecs);
13 }
14 
15 static inline void
16 ndelay(unsigned long nsecs)
17 {
18 	DELAY(MAX(nsecs / 1000, 1));
19 }
20 
21 static inline void
22 usleep_range(unsigned long min, unsigned long max)
23 {
24 	DELAY((min + max) / 2);
25 }
26 
27 static inline void
28 mdelay(unsigned long msecs)
29 {
30 	int loops = msecs;
31 	while (loops--)
32 		DELAY(1000);
33 }
34 
35 #define drm_msleep(x)		mdelay(x)
36 
37 static inline void
38 fsleep(unsigned long usecs)
39 {
40 	DELAY(usecs);
41 }
42 
43 static inline unsigned int
44 msleep_interruptible(unsigned int msecs)
45 {
46 	int r = tsleep_nsec(&nowake, PWAIT|PCATCH, "msleepi",
47 	    MSEC_TO_NSEC(msecs));
48 	if (r == EINTR)
49 		return 1;
50 	return 0;
51 }
52 
53 #endif
54