-extern long ___test_and_set_bit(unsigned long nr, volatile unsigned long *addr);
-extern long ___test_and_clear_bit(unsigned long nr, volatile unsigned long *addr);
-extern long ___test_and_change_bit(unsigned long nr, volatile unsigned long *addr);
-
-#define test_and_set_bit(nr,addr) ({___test_and_set_bit(nr,addr)!=0;})
-#define test_and_clear_bit(nr,addr) ({___test_and_clear_bit(nr,addr)!=0;})
-#define test_and_change_bit(nr,addr) ({___test_and_change_bit(nr,addr)!=0;})
-#define set_bit(nr,addr) ((void)___test_and_set_bit(nr,addr))
-#define clear_bit(nr,addr) ((void)___test_and_clear_bit(nr,addr))
-#define change_bit(nr,addr) ((void)___test_and_change_bit(nr,addr))
-
-/* "non-atomic" versions... */
-
-static __inline__ void __set_bit(int nr, volatile unsigned long *addr)
-{
- volatile unsigned long *m = addr + (nr >> 6);
-
- *m |= (1UL << (nr & 63));
-}
-
-static __inline__ void __clear_bit(int nr, volatile unsigned long *addr)
-{
- volatile unsigned long *m = addr + (nr >> 6);
-
- *m &= ~(1UL << (nr & 63));
-}
-
-static __inline__ void __change_bit(int nr, volatile unsigned long *addr)
-{
- volatile unsigned long *m = addr + (nr >> 6);
-
- *m ^= (1UL << (nr & 63));
-}
-
-static __inline__ int __test_and_set_bit(int nr, volatile unsigned long *addr)
-{
- volatile unsigned long *m = addr + (nr >> 6);
- long old = *m;
- long mask = (1UL << (nr & 63));
-
- *m = (old | mask);
- return ((old & mask) != 0);
-}
-
-static __inline__ int __test_and_clear_bit(int nr, volatile unsigned long *addr)
-{
- volatile unsigned long *m = addr + (nr >> 6);
- long old = *m;
- long mask = (1UL << (nr & 63));
-
- *m = (old & ~mask);
- return ((old & mask) != 0);
-}
-
-static __inline__ int __test_and_change_bit(int nr, volatile unsigned long *addr)
-{
- volatile unsigned long *m = addr + (nr >> 6);
- long old = *m;
- long mask = (1UL << (nr & 63));
-
- *m = (old ^ mask);
- return ((old & mask) != 0);
-}
-
-#define smp_mb__before_clear_bit() do { } while(0)
-#define smp_mb__after_clear_bit() do { } while(0)
-
-static __inline__ int test_bit(int nr, __const__ volatile unsigned long *addr)
-{
- return (1UL & ((addr)[nr >> 6] >> (nr & 63))) != 0UL;
-}
-
-/* The easy/cheese version for now. */
-static __inline__ unsigned long ffz(unsigned long word)
-{
- unsigned long result;
-
- result = 0;
- while(word & 1) {
- result++;
- word >>= 1;
- }
- return result;
-}
-
-/**
- * __ffs - find first bit in word.
- * @word: The word to search
- *
- * Undefined if no bit exists, so code should check against 0 first.
- */
-static __inline__ unsigned long __ffs(unsigned long word)
-{
- unsigned long result = 0;
-
- while (!(word & 1UL)) {
- result++;
- word >>= 1;
- }
- return result;
-}
-
-/*
- * fls: find last bit set.
- */
+extern int test_and_set_bit(unsigned long nr, volatile unsigned long *addr);
+extern int test_and_clear_bit(unsigned long nr, volatile unsigned long *addr);
+extern int test_and_change_bit(unsigned long nr, volatile unsigned long *addr);
+extern void set_bit(unsigned long nr, volatile unsigned long *addr);
+extern void clear_bit(unsigned long nr, volatile unsigned long *addr);
+extern void change_bit(unsigned long nr, volatile unsigned long *addr);
+
+#include <asm-generic/bitops/non-atomic.h>
+
+#ifdef CONFIG_SMP
+#define smp_mb__before_clear_bit() membar_storeload_loadload()
+#define smp_mb__after_clear_bit() membar_storeload_storestore()
+#else
+#define smp_mb__before_clear_bit() barrier()
+#define smp_mb__after_clear_bit() barrier()
+#endif