xref: /openbsd-src/sys/dev/pci/drm/include/linux/delay.h (revision 1ad61ae0a79a724d2d3ec69e69c8e1d1ff6b53a0)
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 unsigned int
38 msleep_interruptible(unsigned int msecs)
39 {
40 	int r = tsleep_nsec(&nowake, PWAIT|PCATCH, "msleepi",
41 	    MSEC_TO_NSEC(msecs));
42 	if (r == EINTR)
43 		return 1;
44 	return 0;
45 }
46 
47 #endif
48