delay.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef __ASM_GENERIC_DELAY_H
  2. #define __ASM_GENERIC_DELAY_H
  3. /* Undefined functions to get compile-time errors */
  4. extern void __bad_udelay(void);
  5. extern void __bad_ndelay(void);
  6. extern void __udelay(unsigned long usecs);
  7. extern void __ndelay(unsigned long nsecs);
  8. extern void __const_udelay(unsigned long xloops);
  9. extern void __delay(unsigned long loops);
  10. /*
  11. * The weird n/20000 thing suppresses a "comparison is always false due to
  12. * limited range of data type" warning with non-const 8-bit arguments.
  13. */
  14. /* 0x10c7 is 2**32 / 1000000 (rounded up) */
  15. #define udelay(n) \
  16. ({ \
  17. if (__builtin_constant_p(n)) { \
  18. if ((n) / 20000 >= 1) \
  19. __bad_udelay(); \
  20. else \
  21. __const_udelay((n) * 0x10c7ul); \
  22. } else { \
  23. __udelay(n); \
  24. } \
  25. })
  26. /* 0x5 is 2**32 / 1000000000 (rounded up) */
  27. #define ndelay(n) \
  28. ({ \
  29. if (__builtin_constant_p(n)) { \
  30. if ((n) / 20000 >= 1) \
  31. __bad_ndelay(); \
  32. else \
  33. __const_udelay((n) * 5ul); \
  34. } else { \
  35. __ndelay(n); \
  36. } \
  37. })
  38. #endif /* __ASM_GENERIC_DELAY_H */