Commit 148817ba authored by Akinobu Mita's avatar Akinobu Mita Committed by Linus Torvalds

asm-generic: add another generic ext2 atomic bitops

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: default avatarAkinobu Mita <akinobu.mita@gmail.com>
Suggested-by: default avatarAndreas Dilger <adilger@dilger.ca>
Suggested-by: default avatarArnd Bergmann <arnd@arndb.de>
Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent b2c9cd37
...@@ -456,8 +456,7 @@ sched_find_first_bit(const unsigned long b[2]) ...@@ -456,8 +456,7 @@ sched_find_first_bit(const unsigned long b[2])
#include <asm-generic/bitops/le.h> #include <asm-generic/bitops/le.h>
#define ext2_set_bit_atomic(l,n,a) test_and_set_bit(n,a) #include <asm-generic/bitops/ext2-atomic-setbit.h>
#define ext2_clear_bit_atomic(l,n,a) test_and_clear_bit(n,a)
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
......
...@@ -310,10 +310,7 @@ static inline int find_next_bit_le(const void *p, int size, int offset) ...@@ -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. * Ext2 is defined to use little-endian byte ordering.
*/ */
#define ext2_set_bit_atomic(lock, nr, p) \ #include <asm-generic/bitops/ext2-atomic-setbit.h>
test_and_set_bit_le(nr, p)
#define ext2_clear_bit_atomic(lock, nr, p) \
test_and_clear_bit_le(nr, p)
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
......
...@@ -156,8 +156,7 @@ static inline int test_and_change_bit(int nr, volatile unsigned long *addr) ...@@ -156,8 +156,7 @@ static inline int test_and_change_bit(int nr, volatile unsigned long *addr)
#include <asm-generic/bitops/le.h> #include <asm-generic/bitops/le.h>
#define ext2_set_bit_atomic(l,n,a) test_and_set_bit(n,a) #include <asm-generic/bitops/ext2-atomic-setbit.h>
#define ext2_clear_bit_atomic(l,n,a) test_and_clear_bit(n,a)
#include <asm-generic/bitops/sched.h> #include <asm-generic/bitops/sched.h>
......
...@@ -403,8 +403,7 @@ int __ilog2_u64(u64 n) ...@@ -403,8 +403,7 @@ int __ilog2_u64(u64 n)
#include <asm-generic/bitops/le.h> #include <asm-generic/bitops/le.h>
#define ext2_set_bit_atomic(lock,nr,addr) test_and_set_bit ((nr) ^ 0x18, (addr)) #include <asm-generic/bitops/ext2-atomic-setbit.h>
#define ext2_clear_bit_atomic(lock,nr,addr) test_and_clear_bit((nr) ^ 0x18, (addr))
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
......
...@@ -458,8 +458,7 @@ static __inline__ unsigned long __arch_hweight64(unsigned long x) ...@@ -458,8 +458,7 @@ static __inline__ unsigned long __arch_hweight64(unsigned long x)
#include <asm-generic/bitops/le.h> #include <asm-generic/bitops/le.h>
#define ext2_set_bit_atomic(l,n,a) test_and_set_bit(n,a) #include <asm-generic/bitops/ext2-atomic-setbit.h>
#define ext2_clear_bit_atomic(l,n,a) test_and_clear_bit(n,a)
#include <asm-generic/bitops/sched.h> #include <asm-generic/bitops/sched.h>
......
...@@ -227,12 +227,7 @@ int ffs(int x) ...@@ -227,12 +227,7 @@ int ffs(int x)
#include <asm-generic/bitops/find.h> #include <asm-generic/bitops/find.h>
#include <asm-generic/bitops/sched.h> #include <asm-generic/bitops/sched.h>
#include <asm-generic/bitops/hweight.h> #include <asm-generic/bitops/hweight.h>
#include <asm-generic/bitops/ext2-atomic-setbit.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/le.h> #include <asm-generic/bitops/le.h>
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
......
...@@ -223,14 +223,7 @@ static __inline__ int fls(int x) ...@@ -223,14 +223,7 @@ static __inline__ int fls(int x)
#ifdef __KERNEL__ #ifdef __KERNEL__
#include <asm-generic/bitops/le.h> #include <asm-generic/bitops/le.h>
#include <asm-generic/bitops/ext2-atomic-setbit.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)
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
......
...@@ -327,10 +327,7 @@ unsigned long find_next_bit_le(const void *addr, ...@@ -327,10 +327,7 @@ unsigned long find_next_bit_le(const void *addr,
unsigned long size, unsigned long offset); unsigned long size, unsigned long offset);
/* Bitmap functions for the ext2 filesystem */ /* Bitmap functions for the ext2 filesystem */
#define ext2_set_bit_atomic(lock, nr, addr) \ #include <asm-generic/bitops/ext2-atomic-setbit.h>
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/sched.h> #include <asm-generic/bitops/sched.h>
......
...@@ -832,10 +832,7 @@ static inline int find_next_bit_le(void *vaddr, unsigned long size, ...@@ -832,10 +832,7 @@ static inline int find_next_bit_le(void *vaddr, unsigned long size,
#include <asm-generic/bitops/le.h> #include <asm-generic/bitops/le.h>
#define ext2_set_bit_atomic(lock, nr, addr) \ #include <asm-generic/bitops/ext2-atomic-setbit.h>
test_and_set_bit_le(nr, addr)
#define ext2_clear_bit_atomic(lock, nr, addr) \
test_and_clear_bit_le(nr, addr)
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
......
...@@ -91,10 +91,7 @@ static inline unsigned int __arch_hweight8(unsigned int w) ...@@ -91,10 +91,7 @@ static inline unsigned int __arch_hweight8(unsigned int w)
#include <asm-generic/bitops/le.h> #include <asm-generic/bitops/le.h>
#define ext2_set_bit_atomic(lock,nr,addr) \ #include <asm-generic/bitops/ext2-atomic-setbit.h>
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))
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
......
...@@ -97,9 +97,6 @@ static inline int test_and_change_bit(unsigned nr, ...@@ -97,9 +97,6 @@ static inline int test_and_change_bit(unsigned nr,
return (oldval & mask) != 0; return (oldval & mask) != 0;
} }
#define ext2_set_bit_atomic(lock, nr, addr) \ #include <asm-generic/bitops/ext2-atomic-setbit.h>
test_and_set_bit((nr), (unsigned long *)(addr))
#define ext2_clear_bit_atomic(lock, nr, addr) \
test_and_clear_bit((nr), (unsigned long *)(addr))
#endif /* _ASM_TILE_BITOPS_64_H */ #endif /* _ASM_TILE_BITOPS_64_H */
...@@ -458,10 +458,7 @@ static inline int fls(int x) ...@@ -458,10 +458,7 @@ static inline int fls(int x)
#include <asm-generic/bitops/le.h> #include <asm-generic/bitops/le.h>
#define ext2_set_bit_atomic(lock, nr, addr) \ #include <asm-generic/bitops/ext2-atomic-setbit.h>
test_and_set_bit((nr), (unsigned long *)(addr))
#define ext2_clear_bit_atomic(lock, nr, addr) \
test_and_clear_bit((nr), (unsigned long *)(addr))
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
#endif /* _ASM_X86_BITOPS_H */ #endif /* _ASM_X86_BITOPS_H */
...@@ -108,19 +108,7 @@ static inline unsigned long __fls(unsigned long word) ...@@ -108,19 +108,7 @@ static inline unsigned long __fls(unsigned long word)
#include <asm-generic/bitops/find.h> #include <asm-generic/bitops/find.h>
#include <asm-generic/bitops/le.h> #include <asm-generic/bitops/le.h>
#ifdef __XTENSA_EL__ #include <asm-generic/bitops/ext2-atomic-setbit.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))
#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/hweight.h> #include <asm-generic/bitops/hweight.h>
#include <asm-generic/bitops/lock.h> #include <asm-generic/bitops/lock.h>
......
#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_ */
#ifndef _ASM_GENERIC_BITOPS_EXT2_ATOMIC_H_ #ifndef _ASM_GENERIC_BITOPS_EXT2_ATOMIC_H_
#define _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) \ #define ext2_set_bit_atomic(lock, nr, addr) \
({ \ ({ \
int ret; \ int ret; \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment