All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/4]: bitops cleanup and fixes
@ 2009-08-18  9:08 Simon Kagstrom
  2009-08-18  9:10 ` [U-Boot] [PATCH 1/4]: Move __set/clear_bit from ubifs.h to bitops.h Simon Kagstrom
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Simon Kagstrom @ 2009-08-18  9:08 UTC (permalink / raw)
  To: u-boot

Hi again!

This patch series is an update to "[PATCH 0/8]: Fixes for ubifs build
on ARM" sent in july:

  http://lists.denx.de/pipermail/u-boot/2009-July/055594.html

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.

  0002-Define-ffs-fls-for-all-architectures.patch
    - Code style updates (Wolfgangs comment).

  0003-Remove-duplicate-set_cr.patch
    - New patch, removes a duplicate definition (also unused) that
      prevents compilation of the next patch

  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. The endianness issue in __test_and_set_bit
      (Jean-Christophes comment) is a separate issue and should be
      handled in a separate patch I think.

// Simon

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH 1/4]: Move __set/clear_bit from ubifs.h to bitops.h
  2009-08-18  9:08 [U-Boot] [PATCH 0/4]: bitops cleanup and fixes Simon Kagstrom
@ 2009-08-18  9:10 ` Simon Kagstrom
  2009-08-19 23:12   ` Jean-Christophe PLAGNIOL-VILLARD
  2009-08-18  9:13 ` [U-Boot] [PATCH 2/4]: Define ffs/fls for all architectures Simon Kagstrom
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 12+ messages in thread
From: Simon Kagstrom @ 2009-08-18  9:10 UTC (permalink / raw)
  To: u-boot

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.

v2: Unify code style (newline between __set_bit and __clear_bit)

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     |   30 ++++++++++++++++++++++++++++++
 9 files changed, 59 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..6bdaad7 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -69,4 +69,34 @@ static inline unsigned int generic_hweight8(unsigned int w)
 #include <asm/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 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
-- 
1.6.0.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH 2/4]: Define ffs/fls for all architectures
  2009-08-18  9:08 [U-Boot] [PATCH 0/4]: bitops cleanup and fixes Simon Kagstrom
  2009-08-18  9:10 ` [U-Boot] [PATCH 1/4]: Move __set/clear_bit from ubifs.h to bitops.h Simon Kagstrom
@ 2009-08-18  9:13 ` Simon Kagstrom
  2009-08-19 23:11   ` Jean-Christophe PLAGNIOL-VILLARD
  2009-08-18  9:13 ` [U-Boot] [PATCH 3/4]: Remove duplicate set_cr Simon Kagstrom
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 12+ messages in thread
From: Simon Kagstrom @ 2009-08-18  9:13 UTC (permalink / raw)
  To: u-boot

Define ffs/fls for all architectures

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 4b8bab2..e98dd56 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)
 
@@ -117,6 +119,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 6bdaad7..fcbd91f 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
-- 
1.6.0.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH 3/4]: Remove duplicate set_cr
  2009-08-18  9:08 [U-Boot] [PATCH 0/4]: bitops cleanup and fixes Simon Kagstrom
  2009-08-18  9:10 ` [U-Boot] [PATCH 1/4]: Move __set/clear_bit from ubifs.h to bitops.h Simon Kagstrom
  2009-08-18  9:13 ` [U-Boot] [PATCH 2/4]: Define ffs/fls for all architectures Simon Kagstrom
@ 2009-08-18  9:13 ` Simon Kagstrom
  2009-08-19 23:06   ` Jean-Christophe PLAGNIOL-VILLARD
  2009-08-18  9:14 ` [U-Boot] [PATCH 4/4]: Define test_and_set_bit and test_and_clear bit for ARM Simon Kagstrom
  2009-08-19 22:56 ` [U-Boot] [PATCH 0/4]: bitops cleanup and fixes Jean-Christophe PLAGNIOL-VILLARD
  4 siblings, 1 reply; 12+ messages in thread
From: Simon Kagstrom @ 2009-08-18  9:13 UTC (permalink / raw)
  To: u-boot

Remove duplicate set_cr

set_cr is defined in both asm-arm/proc-armv/system.h and
include/asm-arm/system.h. This patch removes it (and some duplicate
defines) from the former.

Signed-off-by: Simon Kagstrom <simon.kagstrom@netinsight.net>
---
 include/asm-arm/proc-armv/system.h |   30 ------------------------------
 1 files changed, 0 insertions(+), 30 deletions(-)

diff --git a/include/asm-arm/proc-armv/system.h b/include/asm-arm/proc-armv/system.h
index e7b0fe6..b4cfa68 100644
--- a/include/asm-arm/proc-armv/system.h
+++ b/include/asm-arm/proc-armv/system.h
@@ -12,36 +12,6 @@
 
 #include <linux/config.h>
 
-#define set_cr(x)					\
-	__asm__ __volatile__(				\
-	"mcr	p15, 0, %0, c1, c0	@ set CR"	\
-	: : "r" (x))
-
-#define CR_M	(1 << 0)	/* MMU enable				*/
-#define CR_A	(1 << 1)	/* Alignment abort enable		*/
-#define CR_C	(1 << 2)	/* Dcache enable			*/
-#define CR_W	(1 << 3)	/* Write buffer enable			*/
-#define CR_P	(1 << 4)	/* 32-bit exception handler		*/
-#define CR_D	(1 << 5)	/* 32-bit data address range		*/
-#define CR_L	(1 << 6)	/* Implementation defined		*/
-#define CD_B	(1 << 7)	/* Big endian				*/
-#define CR_S	(1 << 8)	/* System MMU protection		*/
-#define CD_R	(1 << 9)	/* ROM MMU protection			*/
-#define CR_F	(1 << 10)	/* Implementation defined		*/
-#define CR_Z	(1 << 11)	/* Implementation defined		*/
-#define CR_I	(1 << 12)	/* Icache enable			*/
-#define CR_V	(1 << 13)	/* Vectors relocated to 0xffff0000	*/
-#define CR_RR	(1 << 14)	/* Round Robin cache replacement	*/
-
-extern unsigned long cr_no_alignment;	/* defined in entry-armv.S */
-extern unsigned long cr_alignment;	/* defined in entry-armv.S */
-
-#if __LINUX_ARM_ARCH__ >= 4
-#define vectors_base()	((cr_alignment & CR_V) ? 0xffff0000 : 0)
-#else
-#define vectors_base()	(0)
-#endif
-
 /*
  * Save the current interrupt enable state & disable IRQs
  */
-- 
1.6.0.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH 4/4]: Define test_and_set_bit and test_and_clear bit for ARM
  2009-08-18  9:08 [U-Boot] [PATCH 0/4]: bitops cleanup and fixes Simon Kagstrom
                   ` (2 preceding siblings ...)
  2009-08-18  9:13 ` [U-Boot] [PATCH 3/4]: Remove duplicate set_cr Simon Kagstrom
@ 2009-08-18  9:14 ` Simon Kagstrom
  2009-08-19 23:15   ` Jean-Christophe PLAGNIOL-VILLARD
  2009-08-19 22:56 ` [U-Boot] [PATCH 0/4]: bitops cleanup and fixes Jean-Christophe PLAGNIOL-VILLARD
  4 siblings, 1 reply; 12+ messages in thread
From: Simon Kagstrom @ 2009-08-18  9:14 UTC (permalink / raw)
  To: u-boot

Define test_and_set_bit and test_and_clear bit for ARM

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 e98dd56..7ae7aab 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)
@@ -46,8 +47,6 @@ static inline void __change_bit(int nr, volatile void *addr)
 	((unsigned char *) addr)[nr >> 3] ^= (1U << (nr & 7));
 }
 
-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);
@@ -58,7 +57,17 @@ static inline int __test_and_set_bit(int nr, volatile void *addr)
 	return oldval & mask;
 }
 
-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)
 {
@@ -70,6 +79,18 @@ static inline int __test_and_clear_bit(int nr, volatile void *addr)
 	return oldval & mask;
 }
 
+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)
-- 
1.6.0.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH 0/4]: bitops cleanup and fixes
  2009-08-18  9:08 [U-Boot] [PATCH 0/4]: bitops cleanup and fixes Simon Kagstrom
                   ` (3 preceding siblings ...)
  2009-08-18  9:14 ` [U-Boot] [PATCH 4/4]: Define test_and_set_bit and test_and_clear bit for ARM Simon Kagstrom
@ 2009-08-19 22:56 ` Jean-Christophe PLAGNIOL-VILLARD
  4 siblings, 0 replies; 12+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2009-08-19 22:56 UTC (permalink / raw)
  To: u-boot

On 11:08 Tue 18 Aug     , Simon Kagstrom wrote:
> Hi again!
> 
> This patch series is an update to "[PATCH 0/8]: Fixes for ubifs build
> on ARM" sent in july:
> 
>   http://lists.denx.de/pipermail/u-boot/2009-July/055594.html
> 
> 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.
> 
>   0002-Define-ffs-fls-for-all-architectures.patch
>     - Code style updates (Wolfgangs comment).
> 
>   0003-Remove-duplicate-set_cr.patch
>     - New patch, removes a duplicate definition (also unused) that
>       prevents compilation of the next patch
> 
>   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. The endianness issue in __test_and_set_bit
>       (Jean-Christophes comment) is a separate issue and should be
>       handled in a separate patch I think.
but must be part of this cleanup otherwise it will never be done correctly
and some arch as IXP will not work as there are not necessarely in little
endian

Best Regards,
J.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH 3/4]: Remove duplicate set_cr
  2009-08-18  9:13 ` [U-Boot] [PATCH 3/4]: Remove duplicate set_cr Simon Kagstrom
@ 2009-08-19 23:06   ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 12+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2009-08-19 23:06 UTC (permalink / raw)
  To: u-boot

On 11:13 Tue 18 Aug     , Simon Kagstrom wrote:
> Remove duplicate set_cr
> 
> set_cr is defined in both asm-arm/proc-armv/system.h and
> include/asm-arm/system.h. This patch removes it (and some duplicate
> defines) from the former.
> 
> Signed-off-by: Simon Kagstrom <simon.kagstrom@netinsight.net>
> ---
>  include/asm-arm/proc-armv/system.h |   30 ------------------------------
>  1 files changed, 0 insertions(+), 30 deletions(-)
apply to u-boot-arm

Best Regards,
J.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH 2/4]: Define ffs/fls for all architectures
  2009-08-18  9:13 ` [U-Boot] [PATCH 2/4]: Define ffs/fls for all architectures Simon Kagstrom
@ 2009-08-19 23:11   ` Jean-Christophe PLAGNIOL-VILLARD
  2009-08-20  8:42     ` Simon Kagstrom
  0 siblings, 1 reply; 12+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2009-08-19 23:11 UTC (permalink / raw)
  To: u-boot

On 11:13 Tue 18 Aug     , Simon Kagstrom wrote:
> Define ffs/fls for all architectures
> 
> 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)
please this
> 
> Signed-off-by: Simon Kagstrom <simon.kagstrom@netinsight.net>
> ---
here
>  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 +++++++++++++++++++++++++++++++++++++
Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

Best Regards,
J.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH 1/4]: Move __set/clear_bit from ubifs.h to bitops.h
  2009-08-18  9:10 ` [U-Boot] [PATCH 1/4]: Move __set/clear_bit from ubifs.h to bitops.h Simon Kagstrom
@ 2009-08-19 23:12   ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 12+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2009-08-19 23:12 UTC (permalink / raw)
  To: u-boot

On 11:10 Tue 18 Aug     , Simon Kagstrom wrote:
> 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.
> 
> v2: Unify code style (newline between __set_bit and __clear_bit)
please this
> 
> Signed-off-by: Simon Kagstrom <simon.kagstrom@netinsight.net>
> ---
here
>  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     |   30 ++++++++++++++++++++++++++++++
>  9 files changed, 59 insertions(+), 32 deletions(-)
>
Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

Best Regards,
J.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH 4/4]: Define test_and_set_bit and test_and_clear bit for ARM
  2009-08-18  9:14 ` [U-Boot] [PATCH 4/4]: Define test_and_set_bit and test_and_clear bit for ARM Simon Kagstrom
@ 2009-08-19 23:15   ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 12+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2009-08-19 23:15 UTC (permalink / raw)
  To: u-boot

On 11:14 Tue 18 Aug     , Simon Kagstrom wrote:
> Define test_and_set_bit and test_and_clear bit for ARM
> 
> 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(-)
this one NACK as it's must be endianness
for IXP as example

Best Regards,
J.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH 2/4]: Define ffs/fls for all architectures
  2009-08-19 23:11   ` Jean-Christophe PLAGNIOL-VILLARD
@ 2009-08-20  8:42     ` Simon Kagstrom
  2009-08-21 21:59       ` Wolfgang Denk
  0 siblings, 1 reply; 12+ messages in thread
From: Simon Kagstrom @ 2009-08-20  8:42 UTC (permalink / raw)
  To: u-boot

On Thu, 20 Aug 2009 01:11:09 +0200
Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> wrote:

> On 11:13 Tue 18 Aug     , Simon Kagstrom wrote:
> > Define ffs/fls for all architectures
> > 
> > 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)
> please this
> > 
> > Signed-off-by: Simon Kagstrom <simon.kagstrom@netinsight.net>
> > ---
> here

I didn't add that myself - it's  git format-patch  that put it there.

// Simon

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH 2/4]: Define ffs/fls for all architectures
  2009-08-20  8:42     ` Simon Kagstrom
@ 2009-08-21 21:59       ` Wolfgang Denk
  0 siblings, 0 replies; 12+ messages in thread
From: Wolfgang Denk @ 2009-08-21 21:59 UTC (permalink / raw)
  To: u-boot

Dear Simon Kagstrom,

In message <20090820104212.48a033e2@marrow.netinsight.se> you wrote:
> On Thu, 20 Aug 2009 01:11:09 +0200
> Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> wrote:
> 
> > On 11:13 Tue 18 Aug     , Simon Kagstrom wrote:
> > > Define ffs/fls for all architectures
> > > 
> > > 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)
> > please this
> > > 
> > > Signed-off-by: Simon Kagstrom <simon.kagstrom@netinsight.net>
> > > ---
> > here
> 
> I didn't add that myself - it's  git format-patch  that put it there.

What Jean-Christophe means is: Please don't put comments like "v2:
Unify code style ..." in the area where the commit message is, but
move them into the comment section, i. e. below the "---" line.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
To be sure of hitting the target, shoot first and, whatever you  hit,
call it the target.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2009-08-21 21:59 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-18  9:08 [U-Boot] [PATCH 0/4]: bitops cleanup and fixes Simon Kagstrom
2009-08-18  9:10 ` [U-Boot] [PATCH 1/4]: Move __set/clear_bit from ubifs.h to bitops.h Simon Kagstrom
2009-08-19 23:12   ` Jean-Christophe PLAGNIOL-VILLARD
2009-08-18  9:13 ` [U-Boot] [PATCH 2/4]: Define ffs/fls for all architectures Simon Kagstrom
2009-08-19 23:11   ` Jean-Christophe PLAGNIOL-VILLARD
2009-08-20  8:42     ` Simon Kagstrom
2009-08-21 21:59       ` Wolfgang Denk
2009-08-18  9:13 ` [U-Boot] [PATCH 3/4]: Remove duplicate set_cr Simon Kagstrom
2009-08-19 23:06   ` Jean-Christophe PLAGNIOL-VILLARD
2009-08-18  9:14 ` [U-Boot] [PATCH 4/4]: Define test_and_set_bit and test_and_clear bit for ARM Simon Kagstrom
2009-08-19 23:15   ` Jean-Christophe PLAGNIOL-VILLARD
2009-08-19 22:56 ` [U-Boot] [PATCH 0/4]: bitops cleanup and fixes Jean-Christophe PLAGNIOL-VILLARD

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.