bitops.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * Copyright 2004-2009 Analog Devices Inc.
  3. *
  4. * Licensed under the GPL-2 or later.
  5. */
  6. #ifndef _BLACKFIN_BITOPS_H
  7. #define _BLACKFIN_BITOPS_H
  8. #ifndef CONFIG_SMP
  9. # include <asm-generic/bitops.h>
  10. #else
  11. #ifndef _LINUX_BITOPS_H
  12. #error only <linux/bitops.h> can be included directly
  13. #endif
  14. #include <linux/compiler.h>
  15. #include <asm/byteorder.h> /* swab32 */
  16. #include <asm-generic/bitops/ffs.h>
  17. #include <asm-generic/bitops/__ffs.h>
  18. #include <asm-generic/bitops/sched.h>
  19. #include <asm-generic/bitops/ffz.h>
  20. #include <linux/linkage.h>
  21. asmlinkage int __raw_bit_set_asm(volatile unsigned long *addr, int nr);
  22. asmlinkage int __raw_bit_clear_asm(volatile unsigned long *addr, int nr);
  23. asmlinkage int __raw_bit_toggle_asm(volatile unsigned long *addr, int nr);
  24. asmlinkage int __raw_bit_test_set_asm(volatile unsigned long *addr, int nr);
  25. asmlinkage int __raw_bit_test_clear_asm(volatile unsigned long *addr, int nr);
  26. asmlinkage int __raw_bit_test_toggle_asm(volatile unsigned long *addr, int nr);
  27. asmlinkage int __raw_bit_test_asm(const volatile unsigned long *addr, int nr);
  28. static inline void set_bit(int nr, volatile unsigned long *addr)
  29. {
  30. volatile unsigned long *a = addr + (nr >> 5);
  31. __raw_bit_set_asm(a, nr & 0x1f);
  32. }
  33. static inline void clear_bit(int nr, volatile unsigned long *addr)
  34. {
  35. volatile unsigned long *a = addr + (nr >> 5);
  36. __raw_bit_clear_asm(a, nr & 0x1f);
  37. }
  38. static inline void change_bit(int nr, volatile unsigned long *addr)
  39. {
  40. volatile unsigned long *a = addr + (nr >> 5);
  41. __raw_bit_toggle_asm(a, nr & 0x1f);
  42. }
  43. static inline int test_bit(int nr, const volatile unsigned long *addr)
  44. {
  45. volatile const unsigned long *a = addr + (nr >> 5);
  46. return __raw_bit_test_asm(a, nr & 0x1f) != 0;
  47. }
  48. static inline int test_and_set_bit(int nr, volatile unsigned long *addr)
  49. {
  50. volatile unsigned long *a = addr + (nr >> 5);
  51. return __raw_bit_test_set_asm(a, nr & 0x1f);
  52. }
  53. static inline int test_and_clear_bit(int nr, volatile unsigned long *addr)
  54. {
  55. volatile unsigned long *a = addr + (nr >> 5);
  56. return __raw_bit_test_clear_asm(a, nr & 0x1f);
  57. }
  58. static inline int test_and_change_bit(int nr, volatile unsigned long *addr)
  59. {
  60. volatile unsigned long *a = addr + (nr >> 5);
  61. return __raw_bit_test_toggle_asm(a, nr & 0x1f);
  62. }
  63. /*
  64. * clear_bit() doesn't provide any barrier for the compiler.
  65. */
  66. #define smp_mb__before_clear_bit() barrier()
  67. #define smp_mb__after_clear_bit() barrier()
  68. #include <asm-generic/bitops/non-atomic.h>
  69. #include <asm-generic/bitops/find.h>
  70. #include <asm-generic/bitops/hweight.h>
  71. #include <asm-generic/bitops/lock.h>
  72. #include <asm-generic/bitops/ext2-atomic.h>
  73. #include <asm-generic/bitops/ext2-non-atomic.h>
  74. #include <asm-generic/bitops/minix.h>
  75. #include <asm-generic/bitops/fls.h>
  76. #include <asm-generic/bitops/__fls.h>
  77. #include <asm-generic/bitops/fls64.h>
  78. #endif /* CONFIG_SMP */
  79. #endif /* _BLACKFIN_BITOPS_H */