delay.h 1.4 KB

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