summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSimon Kagstrom <simon.kagstrom@netinsight.net>2009-08-24 09:09:50 +0200
committerWolfgang Denk <wd@denx.de>2009-09-15 22:31:24 +0200
commit02f99901ed1c9d828e3ea117f94ce2264bf8389e (patch)
tree1ce78481730fd40db796928a27f34bf5f885ef03 /include
parent557555fe0b82940ba7cc69f81d31d6ef4d4933b4 (diff)
downloadu-boot-imx-02f99901ed1c9d828e3ea117f94ce2264bf8389e.zip
u-boot-imx-02f99901ed1c9d828e3ea117f94ce2264bf8389e.tar.gz
u-boot-imx-02f99901ed1c9d828e3ea117f94ce2264bf8389e.tar.bz2
Move __set/clear_bit from ubifs.h to bitops.h
__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>
Diffstat (limited to 'include')
-rw-r--r--include/asm-arm/bitops.h2
-rw-r--r--include/asm-blackfin/bitops.h1
-rw-r--r--include/asm-microblaze/bitops.h1
-rw-r--r--include/asm-mips/bitops.h1
-rw-r--r--include/linux/bitops.h38
5 files changed, 43 insertions, 0 deletions
diff --git a/include/asm-arm/bitops.h b/include/asm-arm/bitops.h
index 4b8bab2..1549da1 100644
--- a/include/asm-arm/bitops.h
+++ b/include/asm-arm/bitops.h
@@ -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);
diff --git a/include/asm-blackfin/bitops.h b/include/asm-blackfin/bitops.h
index 2e55b6a..cc3685d 100644
--- a/include/asm-blackfin/bitops.h
+++ b/include/asm-blackfin/bitops.h
@@ -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.
diff --git a/include/asm-microblaze/bitops.h b/include/asm-microblaze/bitops.h
index 04ea020..aac9061 100644
--- a/include/asm-microblaze/bitops.h
+++ b/include/asm-microblaze/bitops.h
@@ -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.
diff --git a/include/asm-mips/bitops.h b/include/asm-mips/bitops.h
index 659ac9d..0c07b68 100644
--- a/include/asm-mips/bitops.h
+++ b/include/asm-mips/bitops.h
@@ -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
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index 7d41ae6..387a818 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -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