delay.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 */