[PATCH 02/18] UBIFS: preparation

Renaud Barbier renaud.barbier at ge.com
Mon Dec 3 13:08:18 EST 2012


A new type is added (linux/types.h) in preparation to the introduction of
the UBIFS support. Also functions to do bit operations are added.

Signed-off-by: Renaud Barbier <renaud.barbier at ge.com>
---
 include/linux/bitops.h |   32 ++++++++++++++++++++++++++++++++
 include/linux/types.h  |    2 ++
 2 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index 127c161..a7125fb 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -12,4 +12,36 @@
 #include <asm/bitops.h>
 
 
+#ifndef PLATFORM__SET_BIT
+# define __set_bit generic_set_bit
+#endif
+
+#ifndef PLATFORM__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
diff --git a/include/linux/types.h b/include/linux/types.h
index 76c6b67..888c60e 100644
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -142,6 +142,8 @@ typedef __u64 __bitwise __be64;
 typedef __u16 __bitwise __sum16;
 typedef __u32 __bitwise __wsum;
 
+typedef unsigned __bitwise__ gfp_t;
+
 #ifdef CONFIG_PHYS_ADDR_T_64BIT
 typedef u64 phys_addr_t;
 typedef u64 phys_size_t;
-- 
1.7.1




More information about the barebox mailing list