asm-generic: add another generic ext2 atomic bitops
authorAkinobu Mita <akinobu.mita@gmail.com>
Tue, 26 Jul 2011 23:09:04 +0000 (16:09 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 26 Jul 2011 23:49:46 +0000 (16:49 -0700)
The majority of architectures implement ext2 atomic bitops as
test_and_{set,clear}_bit() without spinlock.

This adds this type of generic implementation in ext2-atomic-setbit.h and
use it wherever possible.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Suggested-by: Andreas Dilger <adilger@dilger.ca>
Suggested-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 files changed:
arch/alpha/include/asm/bitops.h
arch/arm/include/asm/bitops.h
arch/cris/include/asm/bitops.h
arch/frv/include/asm/bitops.h
arch/ia64/include/asm/bitops.h
arch/mn10300/include/asm/bitops.h
arch/parisc/include/asm/bitops.h
arch/powerpc/include/asm/bitops.h
arch/s390/include/asm/bitops.h
arch/sparc/include/asm/bitops_64.h
arch/tile/include/asm/bitops_64.h
arch/x86/include/asm/bitops.h
arch/xtensa/include/asm/bitops.h
include/asm-generic/bitops/ext2-atomic-setbit.h [new file with mode: 0644]
include/asm-generic/bitops/ext2-atomic.h

index 85b815215776d5abce038aa70257351e88be363d..a19ba5efea4ca77f6685108e49f0430ed21663d0 100644 (file)
@@ -456,8 +456,7 @@ sched_find_first_bit(const unsigned long b[2])
 
 #include <asm-generic/bitops/le.h>
 
-#define ext2_set_bit_atomic(l,n,a)   test_and_set_bit(n,a)
-#define ext2_clear_bit_atomic(l,n,a) test_and_clear_bit(n,a)
+#include <asm-generic/bitops/ext2-atomic-setbit.h>
 
 #endif /* __KERNEL__ */
 
index f4280593dfa3a61b9675bfbb35fd2a2b61eb2ed2..f7419ef9c8f99f57a0495bf31453580c6ed43893 100644 (file)
@@ -310,10 +310,7 @@ static inline int find_next_bit_le(const void *p, int size, int offset)
 /*
  * Ext2 is defined to use little-endian byte ordering.
  */
-#define ext2_set_bit_atomic(lock, nr, p)       \
-               test_and_set_bit_le(nr, p)
-#define ext2_clear_bit_atomic(lock, nr, p)     \
-               test_and_clear_bit_le(nr, p)
+#include <asm-generic/bitops/ext2-atomic-setbit.h>
 
 #endif /* __KERNEL__ */
 
index 310e0de67aa6c80911ad99fdaf91b522787ba8f0..c0092fc7d8466829e369323a4dc9ded2cad3bb71 100644 (file)
@@ -156,8 +156,7 @@ static inline int test_and_change_bit(int nr, volatile unsigned long *addr)
 
 #include <asm-generic/bitops/le.h>
 
-#define ext2_set_bit_atomic(l,n,a)   test_and_set_bit(n,a)
-#define ext2_clear_bit_atomic(l,n,a) test_and_clear_bit(n,a)
+#include <asm-generic/bitops/ext2-atomic-setbit.h>
 
 #include <asm-generic/bitops/sched.h>
 
index a1d00b0c6ed71135c0ce113fb70b4080940fd49f..57bf85db893f167b0cb3695c26f6e546d0b7dd04 100644 (file)
@@ -403,8 +403,7 @@ int __ilog2_u64(u64 n)
 
 #include <asm-generic/bitops/le.h>
 
-#define ext2_set_bit_atomic(lock,nr,addr)      test_and_set_bit  ((nr) ^ 0x18, (addr))
-#define ext2_clear_bit_atomic(lock,nr,addr)    test_and_clear_bit((nr) ^ 0x18, (addr))
+#include <asm-generic/bitops/ext2-atomic-setbit.h>
 
 #endif /* __KERNEL__ */
 
index b76f7e009218bec2ed2327caa715f15ce7981aef..8e20bff39f79a9709ea4a16ce0692efcaffe86cb 100644 (file)
@@ -458,8 +458,7 @@ static __inline__ unsigned long __arch_hweight64(unsigned long x)
 
 #include <asm-generic/bitops/le.h>
 
-#define ext2_set_bit_atomic(l,n,a)     test_and_set_bit(n,a)
-#define ext2_clear_bit_atomic(l,n,a)   test_and_clear_bit(n,a)
+#include <asm-generic/bitops/ext2-atomic-setbit.h>
 
 #include <asm-generic/bitops/sched.h>
 
index 0939462967e35d37a33aaf6ab3f86cf5f3bb36e3..596bb2706d81af24c8ae6a59b61ce04096651c68 100644 (file)
@@ -227,12 +227,7 @@ int ffs(int x)
 #include <asm-generic/bitops/find.h>
 #include <asm-generic/bitops/sched.h>
 #include <asm-generic/bitops/hweight.h>
-
-#define ext2_set_bit_atomic(lock, nr, addr) \
-       test_and_set_bit((nr), (addr))
-#define ext2_clear_bit_atomic(lock, nr, addr) \
-       test_and_clear_bit((nr), (addr))
-
+#include <asm-generic/bitops/ext2-atomic-setbit.h>
 #include <asm-generic/bitops/le.h>
 
 #endif /* __KERNEL__ */
index 43c516fa17ff2d47876fa74994c93705bfd3a530..4e833aa05a442bc3054ce0159968101af0c808a5 100644 (file)
@@ -223,14 +223,7 @@ static __inline__ int fls(int x)
 #ifdef __KERNEL__
 
 #include <asm-generic/bitops/le.h>
-
-/* '3' is bits per byte */
-#define LE_BYTE_ADDR ((sizeof(unsigned long) - 1) << 3)
-
-#define ext2_set_bit_atomic(l,nr,addr) \
-               test_and_set_bit((nr)   ^ LE_BYTE_ADDR, (unsigned long *)addr)
-#define ext2_clear_bit_atomic(l,nr,addr) \
-               test_and_clear_bit( (nr) ^ LE_BYTE_ADDR, (unsigned long *)addr)
+#include <asm-generic/bitops/ext2-atomic-setbit.h>
 
 #endif /* __KERNEL__ */
 
index f18c6d9b9510aad8049fe0fb791bc5c9931a7499..e137afcc10fae89cb0987bbe982af5653916e9e1 100644 (file)
@@ -327,10 +327,7 @@ unsigned long find_next_bit_le(const void *addr,
                                    unsigned long size, unsigned long offset);
 /* Bitmap functions for the ext2 filesystem */
 
-#define ext2_set_bit_atomic(lock, nr, addr) \
-       test_and_set_bit_le((nr), (unsigned long*)addr)
-#define ext2_clear_bit_atomic(lock, nr, addr) \
-       test_and_clear_bit_le((nr), (unsigned long*)addr)
+#include <asm-generic/bitops/ext2-atomic-setbit.h>
 
 #include <asm-generic/bitops/sched.h>
 
index 667c6e9f6a34bf569d1d1441af55eec2d02d3e37..e5beb490959bcea55fce5e2051061db7d0885bea 100644 (file)
@@ -832,10 +832,7 @@ static inline int find_next_bit_le(void *vaddr, unsigned long size,
 
 #include <asm-generic/bitops/le.h>
 
-#define ext2_set_bit_atomic(lock, nr, addr)    \
-       test_and_set_bit_le(nr, addr)
-#define ext2_clear_bit_atomic(lock, nr, addr)  \
-       test_and_clear_bit_le(nr, addr)
+#include <asm-generic/bitops/ext2-atomic-setbit.h>
 
 
 #endif /* __KERNEL__ */
index 38e9aa1b2cea390528c7b75a06927b8938e597ce..325e295d60deb2b8d6efced54f06fb70c32c9279 100644 (file)
@@ -91,10 +91,7 @@ static inline unsigned int __arch_hweight8(unsigned int w)
 
 #include <asm-generic/bitops/le.h>
 
-#define ext2_set_bit_atomic(lock,nr,addr) \
-       test_and_set_bit((nr) ^ 0x38,(unsigned long *)(addr))
-#define ext2_clear_bit_atomic(lock,nr,addr) \
-       test_and_clear_bit((nr) ^ 0x38,(unsigned long *)(addr))
+#include <asm-generic/bitops/ext2-atomic-setbit.h>
 
 #endif /* __KERNEL__ */
 
index 99615e8d2d8baf7677ae70142cdc2504b4896b2f..68f8c5bc06797f3a00a3650f06da45a04abb299b 100644 (file)
@@ -97,9 +97,6 @@ static inline int test_and_change_bit(unsigned nr,
        return (oldval & mask) != 0;
 }
 
-#define ext2_set_bit_atomic(lock, nr, addr)                    \
-       test_and_set_bit((nr), (unsigned long *)(addr))
-#define ext2_clear_bit_atomic(lock, nr, addr)                  \
-       test_and_clear_bit((nr), (unsigned long *)(addr))
+#include <asm-generic/bitops/ext2-atomic-setbit.h>
 
 #endif /* _ASM_TILE_BITOPS_64_H */
index 69d58131bc8e185c5be704288e971e0757bc8eab..1775d6e5920e1b8f2a463600a048a9e3b097d978 100644 (file)
@@ -458,10 +458,7 @@ static inline int fls(int x)
 
 #include <asm-generic/bitops/le.h>
 
-#define ext2_set_bit_atomic(lock, nr, addr)                    \
-       test_and_set_bit((nr), (unsigned long *)(addr))
-#define ext2_clear_bit_atomic(lock, nr, addr)                  \
-       test_and_clear_bit((nr), (unsigned long *)(addr))
+#include <asm-generic/bitops/ext2-atomic-setbit.h>
 
 #endif /* __KERNEL__ */
 #endif /* _ASM_X86_BITOPS_H */
index c8fac8d8190dfaeafcf9a27f96122d0fe468b4ad..40aa7fe77f668464450126184297e22aac51410d 100644 (file)
@@ -108,19 +108,7 @@ static inline unsigned long __fls(unsigned long word)
 #include <asm-generic/bitops/find.h>
 #include <asm-generic/bitops/le.h>
 
-#ifdef __XTENSA_EL__
-# define ext2_set_bit_atomic(lock,nr,addr)                             \
-       test_and_set_bit((nr), (unsigned long*)(addr))
-# define ext2_clear_bit_atomic(lock,nr,addr)                           \
-       test_and_clear_bit((nr), (unsigned long*)(addr))
-#elif defined(__XTENSA_EB__)
-# define ext2_set_bit_atomic(lock,nr,addr)                             \
-       test_and_set_bit((nr) ^ 0x18, (unsigned long*)(addr))
-# define ext2_clear_bit_atomic(lock,nr,addr)                           \
-       test_and_clear_bit((nr) ^ 0x18, (unsigned long*)(addr))
-#else
-# error processor byte order undefined!
-#endif
+#include <asm-generic/bitops/ext2-atomic-setbit.h>
 
 #include <asm-generic/bitops/hweight.h>
 #include <asm-generic/bitops/lock.h>
diff --git a/include/asm-generic/bitops/ext2-atomic-setbit.h b/include/asm-generic/bitops/ext2-atomic-setbit.h
new file mode 100644 (file)
index 0000000..5a09978
--- /dev/null
@@ -0,0 +1,11 @@
+#ifndef _ASM_GENERIC_BITOPS_EXT2_ATOMIC_SETBIT_H_
+#define _ASM_GENERIC_BITOPS_EXT2_ATOMIC_SETBIT_H_
+
+/*
+ * Atomic bitops based version of ext2 atomic bitops
+ */
+
+#define ext2_set_bit_atomic(l, nr, addr)       test_and_set_bit_le(nr, addr)
+#define ext2_clear_bit_atomic(l, nr, addr)     test_and_clear_bit_le(nr, addr)
+
+#endif /* _ASM_GENERIC_BITOPS_EXT2_ATOMIC_SETBIT_H_ */
index ecf1c9d8a7cc43e8d9adaffecac83c5b9e37ff27..87f0f109d7f1db4eb34ab11744bd30031daab69b 100644 (file)
@@ -1,6 +1,10 @@
 #ifndef _ASM_GENERIC_BITOPS_EXT2_ATOMIC_H_
 #define _ASM_GENERIC_BITOPS_EXT2_ATOMIC_H_
 
+/*
+ * Spinlock based version of ext2 atomic bitops
+ */
+
 #define ext2_set_bit_atomic(lock, nr, addr)            \
        ({                                              \
                int ret;                                \