[U-Boot] [PATCH v2 0/4]: bitops cleanup and fixes

Hi again!
This patch series is an update to "[PATCH 0/4]: bitops cleanup and fixes":
http://article.gmane.org/gmane.comp.boot-loaders.u-boot/66184
and contains the patches which were not accepted. The patches are:
0001-Move-__set-clear_bit-from-ubifs.h-to-bitops.h.patch - Code style updates. I chose to not create asm-generic/include/bitops/ (Jean-Christophes comment) since I feel that should go together with a larger restructuring. - Updated to put BIT_MASK above the include of asm/bitops.h
0002-Make-arm-bitops-endianness-independent.patch - New patch which takes on the endianeess issue in arm bitops
0003-Define-ffs-fls-for-all-architectures.patch - Code style updates (Wolfgangs comment).
0004-Define-test_and_set_bit-and-test_and_clear-bit-for-A.patch - Defines test_and_set_bit etc for ARM. Uses the non-atomic __test_and_set_bit.
remove-dupliace-cr.patch was accepted into the u-boot-arm tree, so I'm not reposting it.
// Simon

__set_bit and __clear_bit are defined in ubifs.h as well as in asm/include/bitops.h for some architectures. This patch moves the generic implementation to include/linux/bitops.h and uses that unless it's defined by the architecture.
v2: Unify code style (newline between __set_bit and __clear_bit) v3: Move BIT_MASK and BIT_WORD above the include of asm/bitops.h
Signed-off-by: Simon Kagstrom simon.kagstrom@netinsight.net --- fs/ubifs/ubifs.h | 32 -------------------------------- include/asm-avr32/bitops.h | 4 ++++ include/asm-m68k/bitops.h | 4 ++++ include/asm-nios/bitops.h | 4 ++++ include/asm-nios2/bitops.h | 4 ++++ include/asm-ppc/bitops.h | 4 ++++ include/asm-sh/bitops.h | 5 +++++ include/asm-sparc/bitops.h | 4 ++++ include/linux/bitops.h | 29 +++++++++++++++++++++++++++++ 9 files changed, 58 insertions(+), 32 deletions(-)
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h index 43865aa..06772af 100644 --- a/fs/ubifs/ubifs.h +++ b/fs/ubifs/ubifs.h @@ -449,38 +449,6 @@ static inline ino_t parent_ino(struct dentry *dentry) return res; }
-/* linux/include/linux/bitops.h */ - -#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) -#define BIT_WORD(nr) ((nr) / BITS_PER_LONG) - -/* linux/include/asm-generic/bitops/non-atomic.h */ - -/** - * __set_bit - Set a bit in memory - * @nr: the bit to set - * @addr: the address to start counting from - * - * Unlike set_bit(), this function is non-atomic and may be reordered. - * If it's called on the same region of memory simultaneously, the effect - * may be that only one operation succeeds. - */ -static inline void __set_bit(int nr, volatile unsigned long *addr) -{ - unsigned long mask = BIT_MASK(nr); - unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); - - *p |= mask; -} - -static inline void __clear_bit(int nr, volatile unsigned long *addr) -{ - unsigned long mask = BIT_MASK(nr); - unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); - - *p &= ~mask; -} - /* debug.c */
#define DEFINE_SPINLOCK(...) diff --git a/include/asm-avr32/bitops.h b/include/asm-avr32/bitops.h index f15fd46..b1cf2fb 100644 --- a/include/asm-avr32/bitops.h +++ b/include/asm-avr32/bitops.h @@ -22,4 +22,8 @@ #ifndef __ASM_AVR32_BITOPS_H #define __ASM_AVR32_BITOPS_H
+#define __set_bit(nr, addr) generic_set_bit(nr, addr) + +#define __clear_bit(nr, addr) generic_clear_bit(nr, addr) + #endif /* __ASM_AVR32_BITOPS_H */ diff --git a/include/asm-m68k/bitops.h b/include/asm-m68k/bitops.h index 0f9e8ab..fb472e6 100644 --- a/include/asm-m68k/bitops.h +++ b/include/asm-m68k/bitops.h @@ -15,6 +15,10 @@ extern int test_and_set_bit(int nr, volatile void *addr); extern int test_and_clear_bit(int nr, volatile void *addr); extern int test_and_change_bit(int nr, volatile void *addr);
+#define __set_bit(nr, addr) generic_set_bit(nr, addr) + +#define __clear_bit(nr, addr) generic_clear_bit(nr, addr) + #ifdef __KERNEL__
/* diff --git a/include/asm-nios/bitops.h b/include/asm-nios/bitops.h index 7744212..76c52c2 100644 --- a/include/asm-nios/bitops.h +++ b/include/asm-nios/bitops.h @@ -34,4 +34,8 @@ extern int test_and_change_bit(int nr, volatile void * addr); extern int test_bit(int nr, volatile void * a); extern int ffs(int i);
+#define __set_bit(nr, addr) generic_set_bit(nr, addr) + +#define __clear_bit(nr, addr) generic_clear_bit(nr, addr) + #endif /* _ASM_NIOS_BITOPS_H */ diff --git a/include/asm-nios2/bitops.h b/include/asm-nios2/bitops.h index e6c1a85..da04b40 100644 --- a/include/asm-nios2/bitops.h +++ b/include/asm-nios2/bitops.h @@ -34,4 +34,8 @@ extern int test_and_change_bit(int nr, volatile void * addr); extern int test_bit(int nr, volatile void * a); extern int ffs(int i);
+#define __set_bit(nr, addr) generic_set_bit(nr, addr) + +#define __clear_bit(nr, addr) generic_clear_bit(nr, addr) + #endif /* __ASM_NIOS2_BITOPS_H */ diff --git a/include/asm-ppc/bitops.h b/include/asm-ppc/bitops.h index daa66cf..fd7f599 100644 --- a/include/asm-ppc/bitops.h +++ b/include/asm-ppc/bitops.h @@ -144,6 +144,10 @@ extern __inline__ int test_and_change_bit(int nr, volatile void *addr) } #endif /* __INLINE_BITOPS */
+#define __set_bit(nr, addr) generic_set_bit(nr, addr) + +#define __clear_bit(nr, addr) generic_clear_bit(nr, addr) + extern __inline__ int test_bit(int nr, __const__ volatile void *addr) { __const__ unsigned int *p = (__const__ unsigned int *) addr; diff --git a/include/asm-sh/bitops.h b/include/asm-sh/bitops.h index 410fba4..f102e7e 100644 --- a/include/asm-sh/bitops.h +++ b/include/asm-sh/bitops.h @@ -146,6 +146,11 @@ static inline int ffs (int x) } return r; } + +#define __set_bit(nr, addr) generic_set_bit(nr, addr) + +#define __clear_bit(nr, addr) generic_clear_bit(nr, addr) + #endif /* __KERNEL__ */
#endif /* __ASM_SH_BITOPS_H */ diff --git a/include/asm-sparc/bitops.h b/include/asm-sparc/bitops.h index ceb39f2..b1bcb53 100644 --- a/include/asm-sparc/bitops.h +++ b/include/asm-sparc/bitops.h @@ -26,4 +26,8 @@ #ifndef _SPARC_BITOPS_H #define _SPARC_BITOPS_H
+#define __set_bit(nr, addr) generic_set_bit(nr, addr) + +#define __clear_bit(nr, addr) generic_clear_bit(nr, addr) + #endif /* _SPARC_BITOPS_H */ diff --git a/include/linux/bitops.h b/include/linux/bitops.h index 7d41ae6..3470823 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -66,7 +66,36 @@ static inline unsigned int generic_hweight8(unsigned int w) return (res & 0x0F) + ((res >> 4) & 0x0F); }
+#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) +#define BIT_WORD(nr) ((nr) / BITS_PER_LONG) + #include <asm/bitops.h>
+/* linux/include/asm-generic/bitops/non-atomic.h */ + +/** + * __set_bit - Set a bit in memory + * @nr: the bit to set + * @addr: the address to start counting from + * + * Unlike set_bit(), this function is non-atomic and may be reordered. + * If it's called on the same region of memory simultaneously, the effect + * may be that only one operation succeeds. + */ +static inline void generic_set_bit(int nr, volatile unsigned long *addr) +{ + unsigned long mask = BIT_MASK(nr); + unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); + + *p |= mask; +} + +static inline void generic_clear_bit(int nr, volatile unsigned long *addr) +{ + unsigned long mask = BIT_MASK(nr); + unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); + + *p &= ~mask; +}
#endif

On Thursday 20 August 2009 04:52:50 Simon Kagstrom wrote:
--- a/include/asm-sh/bitops.h +++ b/include/asm-sh/bitops.h @@ -146,6 +146,11 @@ static inline int ffs (int x) } return r; }
+#define __set_bit(nr, addr) generic_set_bit(nr, addr)
+#define __clear_bit(nr, addr) generic_clear_bit(nr, addr)
this is just silly to put into every arch header. why not do in the common code: #ifndef __set_bit # define __set_bit generice_set_bit #endif -mike

Dear Mike Frysinger,
In message 200908201344.37190.vapier@gentoo.org you wrote:
+#define __set_bit(nr, addr) generic_set_bit(nr, addr)
+#define __clear_bit(nr, addr) generic_clear_bit(nr, addr)
this is just silly to put into every arch header. why not do in the common code: #ifndef __set_bit # define __set_bit generice_set_bit #endif
Because it doesn't work?
The code usually looks like this: "static inline void __set_bit(...)..."
This defines a static inline function, but _not_ a preprocessor variable of that name.
Best regards,
Wolfgang Denk

On Thursday 20 August 2009 14:31:45 Wolfgang Denk wrote:
Mike Frysinger wrote:
+#define __set_bit(nr, addr) generic_set_bit(nr, addr)
+#define __clear_bit(nr, addr) generic_clear_bit(nr, addr)
this is just silly to put into every arch header. why not do in the common code: #ifndef __set_bit # define __set_bit generice_set_bit #endif
Because it doesn't work?
The code usually looks like this: "static inline void __set_bit(...)..."
This defines a static inline function, but _not_ a preprocessor variable of that name.
i know what the code looks like. the obvious extensions was that the arches would do something like: #define __set_bit __set_bit to indicate that they have their own replacement -mike

On Thu, 20 Aug 2009 13:44:35 -0400 Mike Frysinger vapier@gentoo.org wrote:
On Thursday 20 August 2009 04:52:50 Simon Kagstrom wrote:
--- a/include/asm-sh/bitops.h +++ b/include/asm-sh/bitops.h @@ -146,6 +146,11 @@ static inline int ffs (int x) } return r; }
+#define __set_bit(nr, addr) generic_set_bit(nr, addr)
+#define __clear_bit(nr, addr) generic_clear_bit(nr, addr)
this is just silly to put into every arch header. why not do in the common code: #ifndef __set_bit # define __set_bit generice_set_bit #endif
It's a function (static inline) in some architectures.
// Simon

On Friday 21 August 2009 02:05:47 Simon Kagstrom wrote:
On Thu, 20 Aug 2009 13:44:35 -0400 Mike Frysinger wrote:
On Thursday 20 August 2009 04:52:50 Simon Kagstrom wrote:
--- a/include/asm-sh/bitops.h +++ b/include/asm-sh/bitops.h @@ -146,6 +146,11 @@ static inline int ffs (int x) } return r; }
+#define __set_bit(nr, addr) generic_set_bit(nr, addr)
+#define __clear_bit(nr, addr) generic_clear_bit(nr, addr)
this is just silly to put into every arch header. why not do in the common code: #ifndef __set_bit # define __set_bit generice_set_bit #endif
It's a function (static inline) in some architectures.
add the obvious #define i already posted in a later e-mail. it makes a lot more sense for the non-common behavior of providing a custom implementation to add one more line per func than to try and update (and keep up-to-date) every arch using the common code. -mike

On Fri, 21 Aug 2009 02:29:30 -0400 Mike Frysinger vapier@gentoo.org wrote:
this is just silly to put into every arch header. why not do in the common code: #ifndef __set_bit # define __set_bit generice_set_bit #endif
It's a function (static inline) in some architectures.
add the obvious #define i already posted in a later e-mail. it makes a lot more sense for the non-common behavior of providing a custom implementation to add one more line per func than to try and update (and keep up-to-date) every arch using the common code.
Yep, I saw your mail too late. I'll rework the patch series and resubmit.
// Simon

Bring over the bitop implementations from the Linux include/asm-generic/bitops/non-atomic.h to provide endianness-independence.
Signed-off-by: Simon Kagstrom simon.kagstrom@netinsight.net --- include/asm-arm/bitops.h | 45 +++++++++++++++++++++++++++------------------ 1 files changed, 27 insertions(+), 18 deletions(-)
diff --git a/include/asm-arm/bitops.h b/include/asm-arm/bitops.h index 4b8bab2..04ae68c 100644 --- a/include/asm-arm/bitops.h +++ b/include/asm-arm/bitops.h @@ -27,57 +27,66 @@ extern void set_bit(int nr, volatile void * addr);
static inline void __set_bit(int nr, volatile void *addr) { - ((unsigned char *) addr)[nr >> 3] |= (1U << (nr & 7)); + unsigned long mask = BIT_MASK(nr); + unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); + + *p |= mask; }
extern void clear_bit(int nr, volatile void * addr);
static inline void __clear_bit(int nr, volatile void *addr) { - ((unsigned char *) addr)[nr >> 3] &= ~(1U << (nr & 7)); + unsigned long mask = BIT_MASK(nr); + unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); + + *p &= ~mask; }
extern void change_bit(int nr, volatile void * addr);
static inline void __change_bit(int nr, volatile void *addr) { - ((unsigned char *) addr)[nr >> 3] ^= (1U << (nr & 7)); + unsigned long mask = BIT_MASK(nr); + unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); + + *p ^= mask; }
extern int test_and_set_bit(int nr, volatile void * addr);
static inline int __test_and_set_bit(int nr, volatile void *addr) { - unsigned int mask = 1 << (nr & 7); - unsigned int oldval; + unsigned long mask = BIT_MASK(nr); + unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); + unsigned long old = *p;
- oldval = ((unsigned char *) addr)[nr >> 3]; - ((unsigned char *) addr)[nr >> 3] = oldval | mask; - return oldval & mask; + *p = old | mask; + return (old & mask) != 0; }
extern int test_and_clear_bit(int nr, volatile void * addr);
static inline int __test_and_clear_bit(int nr, volatile void *addr) { - unsigned int mask = 1 << (nr & 7); - unsigned int oldval; + unsigned long mask = BIT_MASK(nr); + unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); + unsigned long old = *p;
- oldval = ((unsigned char *) addr)[nr >> 3]; - ((unsigned char *) addr)[nr >> 3] = oldval & ~mask; - return oldval & mask; + *p = old & ~mask; + return (old & mask) != 0; }
extern int test_and_change_bit(int nr, volatile void * addr);
static inline int __test_and_change_bit(int nr, volatile void *addr) { - unsigned int mask = 1 << (nr & 7); - unsigned int oldval; + unsigned long mask = BIT_MASK(nr); + unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); + unsigned long old = *p;
- oldval = ((unsigned char *) addr)[nr >> 3]; - ((unsigned char *) addr)[nr >> 3] = oldval ^ mask; - return oldval & mask; + *p = old ^ mask; + return (old & mask) != 0; }
extern int find_first_zero_bit(void * addr, unsigned size);

UBIFS requires fls(), which is not defined for arm (and some other architectures) and this patch adds it. The implementation is taken from Linux and is generic. ffs() is also defined for those that miss it.
v2: Unify code style (empty line between ffs/fls)
Signed-off-by: Simon Kagstrom simon.kagstrom@netinsight.net --- include/asm-arm/bitops.h | 4 ++++ include/asm-avr32/bitops.h | 4 ++++ include/asm-i386/bitops.h | 2 ++ include/asm-m68k/bitops.h | 2 ++ include/asm-microblaze/bitops.h | 2 ++ include/asm-mips/bitops.h | 2 ++ include/asm-nios/bitops.h | 5 ++++- include/asm-nios2/bitops.h | 5 ++++- include/asm-sh/bitops.h | 2 ++ include/asm-sparc/bitops.h | 4 ++++ include/linux/bitops.h | 37 +++++++++++++++++++++++++++++++++++++ 11 files changed, 67 insertions(+), 2 deletions(-)
diff --git a/include/asm-arm/bitops.h b/include/asm-arm/bitops.h index 04ae68c..b3a9578 100644 --- a/include/asm-arm/bitops.h +++ b/include/asm-arm/bitops.h @@ -17,6 +17,8 @@
#ifdef __KERNEL__
+#include <asm/types.h> + #define smp_mb__before_clear_bit() do { } while (0) #define smp_mb__after_clear_bit() do { } while (0)
@@ -126,6 +128,8 @@ static inline unsigned long ffz(unsigned long word)
#define ffs(x) generic_ffs(x)
+#define fls(x) generic_fls(x) + /* * hweightN: returns the hamming weight (i.e. the number * of bits set) of a N-bit word diff --git a/include/asm-avr32/bitops.h b/include/asm-avr32/bitops.h index b1cf2fb..5fa20e2 100644 --- a/include/asm-avr32/bitops.h +++ b/include/asm-avr32/bitops.h @@ -26,4 +26,8 @@
#define __clear_bit(nr, addr) generic_clear_bit(nr, addr)
+#define ffs(x) generic_ffs(x) + +#define fls(x) generic_fls(x) + #endif /* __ASM_AVR32_BITOPS_H */ diff --git a/include/asm-i386/bitops.h b/include/asm-i386/bitops.h index b768e20..71c2256 100644 --- a/include/asm-i386/bitops.h +++ b/include/asm-i386/bitops.h @@ -350,6 +350,8 @@ static __inline__ int ffs(int x) return r+1; }
+#define fls(x) generic_fls(x) + /** * hweightN - returns the hamming weight of a N-bit word * @x: the word to weigh diff --git a/include/asm-m68k/bitops.h b/include/asm-m68k/bitops.h index fb472e6..a38a62a 100644 --- a/include/asm-m68k/bitops.h +++ b/include/asm-m68k/bitops.h @@ -56,6 +56,8 @@ extern __inline__ int ffs(int x) } #define __ffs(x) (ffs(x) - 1)
+#define fls(x) generic_fls(x) + #endif /* __KERNEL__ */
#endif /* _M68K_BITOPS_H */ diff --git a/include/asm-microblaze/bitops.h b/include/asm-microblaze/bitops.h index 04ea020..e277ab8 100644 --- a/include/asm-microblaze/bitops.h +++ b/include/asm-microblaze/bitops.h @@ -266,6 +266,8 @@ found_middle:
#define ffs(x) generic_ffs(x)
+#define fls(x) generic_fls(x) + /* * hweightN: returns the hamming weight (i.e. the number * of bits set) of a N-bit word diff --git a/include/asm-mips/bitops.h b/include/asm-mips/bitops.h index 659ac9d..76b9baa 100644 --- a/include/asm-mips/bitops.h +++ b/include/asm-mips/bitops.h @@ -716,6 +716,8 @@ static __inline__ unsigned long ffz(unsigned long word)
#define ffs(x) generic_ffs(x)
+#define fls(x) generic_fls(x) + /* * hweightN - returns the hamming weight of a N-bit word * @x: the word to weigh diff --git a/include/asm-nios/bitops.h b/include/asm-nios/bitops.h index 76c52c2..33714c4 100644 --- a/include/asm-nios/bitops.h +++ b/include/asm-nios/bitops.h @@ -32,7 +32,10 @@ extern void change_bit(unsigned long nr, volatile void *addr); extern int test_and_set_bit(int nr, volatile void * a); extern int test_and_change_bit(int nr, volatile void * addr); extern int test_bit(int nr, volatile void * a); -extern int ffs(int i); + +#define ffs(x) generic_ffs(x) + +#define fls(x) generic_fls(x)
#define __set_bit(nr, addr) generic_set_bit(nr, addr)
diff --git a/include/asm-nios2/bitops.h b/include/asm-nios2/bitops.h index da04b40..1fac52c 100644 --- a/include/asm-nios2/bitops.h +++ b/include/asm-nios2/bitops.h @@ -32,7 +32,10 @@ extern void change_bit(unsigned long nr, volatile void *addr); extern int test_and_set_bit(int nr, volatile void * a); extern int test_and_change_bit(int nr, volatile void * addr); extern int test_bit(int nr, volatile void * a); -extern int ffs(int i); + +#define ffs(x) generic_ffs(x) + +#define fls(x) generic_fls(x)
#define __set_bit(nr, addr) generic_set_bit(nr, addr)
diff --git a/include/asm-sh/bitops.h b/include/asm-sh/bitops.h index f102e7e..8021455 100644 --- a/include/asm-sh/bitops.h +++ b/include/asm-sh/bitops.h @@ -147,6 +147,8 @@ static inline int ffs (int x) return r; }
+#define fls(x) generic_fls(x) + #define __set_bit(nr, addr) generic_set_bit(nr, addr)
#define __clear_bit(nr, addr) generic_clear_bit(nr, addr) diff --git a/include/asm-sparc/bitops.h b/include/asm-sparc/bitops.h index b1bcb53..942029f 100644 --- a/include/asm-sparc/bitops.h +++ b/include/asm-sparc/bitops.h @@ -30,4 +30,8 @@
#define __clear_bit(nr, addr) generic_clear_bit(nr, addr)
+#define ffs(x) generic_ffs(x) + +#define fls(x) generic_fls(x) + #endif /* _SPARC_BITOPS_H */ diff --git a/include/linux/bitops.h b/include/linux/bitops.h index 3470823..0500565 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -37,6 +37,43 @@ static inline int generic_ffs(int x) return r; }
+/** + * fls - find last (most-significant) bit set + * @x: the word to search + * + * This is defined the same way as ffs. + * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32. + */ +static inline int generic_fls(int x) +{ + int r = 32; + + if (!x) + return 0; + if (!(x & 0xffff0000u)) { + x <<= 16; + r -= 16; + } + if (!(x & 0xff000000u)) { + x <<= 8; + r -= 8; + } + if (!(x & 0xf0000000u)) { + x <<= 4; + r -= 4; + } + if (!(x & 0xc0000000u)) { + x <<= 2; + r -= 2; + } + if (!(x & 0x80000000u)) { + x <<= 1; + r -= 1; + } + return r; +} + + /* * hweightN: returns the hamming weight (i.e. the number * of bits set) of a N-bit word

Needed for (e.g.) ubifs support to work.
Signed-off-by: Simon Kagstrom simon.kagstrom@netinsight.net --- include/asm-arm/bitops.h | 27 ++++++++++++++++++++++++--- 1 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/include/asm-arm/bitops.h b/include/asm-arm/bitops.h index b3a9578..b62ff90 100644 --- a/include/asm-arm/bitops.h +++ b/include/asm-arm/bitops.h @@ -18,6 +18,7 @@ #ifdef __KERNEL__
#include <asm/types.h> +#include <asm/proc/system.h>
#define smp_mb__before_clear_bit() do { } while (0) #define smp_mb__after_clear_bit() do { } while (0) @@ -55,8 +56,6 @@ static inline void __change_bit(int nr, volatile void *addr) *p ^= mask; }
-extern int test_and_set_bit(int nr, volatile void * addr); - static inline int __test_and_set_bit(int nr, volatile void *addr) { unsigned long mask = BIT_MASK(nr); @@ -67,7 +66,17 @@ static inline int __test_and_set_bit(int nr, volatile void *addr) return (old & mask) != 0; }
-extern int test_and_clear_bit(int nr, volatile void * addr); +static inline int test_and_set_bit(int nr, volatile void * addr) +{ + unsigned long flags; + int out; + + local_irq_save(flags); + out = __test_and_set_bit(nr, addr); + local_irq_restore(flags); + + return out; +}
static inline int __test_and_clear_bit(int nr, volatile void *addr) { @@ -79,6 +88,18 @@ static inline int __test_and_clear_bit(int nr, volatile void *addr) return (old & mask) != 0; }
+static inline int test_and_clear_bit(int nr, volatile void * addr) +{ + unsigned long flags; + int out; + + local_irq_save(flags); + out = __test_and_clear_bit(nr, addr); + local_irq_restore(flags); + + return out; +} + extern int test_and_change_bit(int nr, volatile void * addr);
static inline int __test_and_change_bit(int nr, volatile void *addr)
participants (3)
-
Mike Frysinger
-
Simon Kagstrom
-
Wolfgang Denk