]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
Move __set/clear_bit from ubifs.h to bitops.h
authorSimon Kagstrom <simon.kagstrom@netinsight.net>
Mon, 24 Aug 2009 07:09:50 +0000 (09:09 +0200)
committerTom Rix <Tom.Rix@windriver.com>
Sat, 3 Oct 2009 14:04:25 +0000 (09:04 -0500)
__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.

Signed-off-by: Simon Kagstrom <simon.kagstrom@netinsight.net>
fs/ubifs/ubifs.h
include/asm-arm/bitops.h
include/asm-blackfin/bitops.h
include/asm-microblaze/bitops.h
include/asm-mips/bitops.h
include/linux/bitops.h

index 43865aa66ed90ef9d267f0fec60fabc924160f47..06772af36f71a117fffab0558cb1c0fe14ae9721 100644 (file)
@@ -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(...)
index 4b8bab28373bbe42d8ec17dbb052aea2e95648fd..1549da1693322aaab70ddd704ec2ea99706f13c8 100644 (file)
@@ -29,6 +29,7 @@ static inline void __set_bit(int nr, volatile void *addr)
 {
        ((unsigned char *) addr)[nr >> 3] |= (1U << (nr & 7));
 }
+#define __set_bit
 
 extern void clear_bit(int nr, volatile void * addr);
 
@@ -36,6 +37,7 @@ static inline void __clear_bit(int nr, volatile void *addr)
 {
        ((unsigned char *) addr)[nr >> 3] &= ~(1U << (nr & 7));
 }
+#define __clear_bit
 
 extern void change_bit(int nr, volatile void * addr);
 
index 2e55b6a619998c234aee9042be7f70e960a112d3..cc3685d35d7bd2d09b6b75b24b44dbe56850e983 100644 (file)
@@ -79,6 +79,7 @@ static __inline__ void __set_bit(int nr, volatile void *addr)
        mask = 1 << (nr & 0x1f);
        *a |= mask;
 }
+#define __set_bit
 
 /*
  * clear_bit() doesn't provide any barrier for the compiler.
index 04ea0207eea38cc809f6f53f84411faa484a8c5f..aac906102abc1817c6eddbe2cfd1e6382c33ee7f 100644 (file)
@@ -75,6 +75,7 @@ extern __inline__ void __set_bit(int nr, volatile void * addr)
        mask = 1 << (nr & 0x1f);
        *a |= mask;
 }
+#define __set_bit
 
 /*
  * clear_bit() doesn't provide any barrier for the compiler.
index 659ac9d3201797f38552ef1d301f8eb066bc26ca..0c07b686a2d54de1b8f9b36981192c14d51951bd 100644 (file)
@@ -90,6 +90,7 @@ static __inline__ void __set_bit(int nr, volatile void * addr)
 
        *m |= 1UL << (nr & 31);
 }
+#define __set_bit
 
 /*
  * clear_bit - Clears a bit in memory
index 7d41ae62ccf7ead43fe4a468d6b58624410b7836..387a81813b9903c480fa2bed141284058d863347 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef _LINUX_BITOPS_H
 #define _LINUX_BITOPS_H
 
+#include <asm/types.h>
 
 /*
  * ffs: find first bit set. This is defined the same way as
@@ -66,7 +67,44 @@ 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 */
+
+#ifndef __set_bit
+# define __set_bit generic_set_bit
+#endif
+
+#ifndef __clear_bit
+# define __clear_bit generic_clear_bit
+#endif
+
+/**
+ * __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