Skip to contentSkip to conversation

: bitops cleanup and fixes

PATCH Superseded Simon Kagstrom 5 participants 22 messages Aug 24, 2009 – Sep 17, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v4 cover : bitops cleanup and fixes

Hi yet again!

This update to the patch series just cleans up the commit messages to have the comments in the git comments section.

// Simon

#1 lore raw

PATCH v4 1/4 : Move __set/clear_bit from ubifs.h to bitops.h

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.

---
ChangeLog:
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
v4: Move the definition to generic code (Mike Frysinger)

 fs/ubifs/ubifs.h                |   32 --------------------------------
 include/asm-arm/bitops.h        |    2 ++
 include/asm-blackfin/bitops.h   |    1 +
 include/asm-microblaze/bitops.h |    1 +
 include/asm-mips/bitops.h       |    1 +
 include/linux/bitops.h          |   38 ++++++++++++++++++++++++++++++++++++++
 6 files changed, 43 insertions(+), 32 deletions(-)
fs/ubifs/ubifs.h +0 -32
index 43865aa..06772af 100644
@@ -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(...)
include/asm-arm/bitops.h +2 -0
index 4b8bab2..1549da1 100644
@@ -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);
 
include/asm-blackfin/bitops.h +1 -0
index 2e55b6a..cc3685d 100644
@@ -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.
include/asm-microblaze/bitops.h +1 -0
index 04ea020..aac9061 100644
@@ -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.
include/asm-mips/bitops.h +1 -0
index 659ac9d..0c07b68 100644
@@ -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
include/linux/bitops.h +38 -0
index 7d41ae6..387a818 100644
@@ -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
Signature · 1 line
1.6.0.4
#2 lore raw

PATCH v4 1/4 : Move __set/clear_bit from ubifs.h to bitops.h

Dear Simon Kagstrom,

Quoted 14 lines · In message <[email protected]> you 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.

---
ChangeLog:
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
v4: Move the definition to generic code (Mike Frysinger)

Quoted 7 lines
 fs/ubifs/ubifs.h                |   32 --------------------------------
 include/asm-arm/bitops.h        |    2 ++
 include/asm-blackfin/bitops.h   |    1 +
 include/asm-microblaze/bitops.h |    1 +
 include/asm-mips/bitops.h       |    1 +
 include/linux/bitops.h          |   38 ++++++++++++++++++++++++++++++++++++++
 6 files changed, 43 insertions(+), 32 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
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 live is always desirable.
	-- Eleen the Capellan, "Friday's Child", stardate 3498.9
#3 lore raw

PATCH v4 2/4 : arm: Make arm bitops endianness-independent

In reply to Simon Kagstrom

arm: Make arm bitops endianness-independent

Bring over the bitop implementations from the Linux include/asm-generic/bitops/non-atomic.h to provide endianness-independence.

---
ChangeLog:
v2: Use generic __set_bit and __clear_bit for ARM

 include/asm-arm/bitops.h |   47 ++++++++++++++++++---------------------------
 1 files changed, 19 insertions(+), 28 deletions(-)
include/asm-arm/bitops.h +19 -28
index 1549da1..854e225 100644
@@ -25,61 +25,52 @@
  */
 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));
-}
-#define __set_bit
-
 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));
-}
-#define __clear_bit
-
 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);
Signature · 1 line
1.6.0.4
#4 lore raw

PATCH v4 2/4 : arm: Make arm bitops endianness-independent

Dear Simon Kagstrom,

Quoted 6 lines · In message <[email protected]> you wrote:

arm: Make arm bitops endianness-independent

Bring over the bitop implementations from the Linux include/asm-generic/bitops/non-atomic.h to provide endianness-independence.

Quoted 7 lines

---
ChangeLog:
v2: Use generic __set_bit and __clear_bit for ARM

 include/asm-arm/bitops.h |   47 ++++++++++++++++++---------------------------
 1 files changed, 19 insertions(+), 28 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
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
War is never imperative.
	-- McCoy, "Balance of Terror", stardate 1709.2
#5 lore raw

PATCH v4 3/4 : Define ffs/fls for all architectures

In reply to Simon Kagstrom

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.

---
ChangeLog:
v2: Unify code style (empty line between ffs/fls)
v3: Move the definition to generic code (Mike Frysinger)

 include/asm-i386/bitops.h  |    1 +
 include/asm-m68k/bitops.h  |    1 +
 include/asm-nios/bitops.h  |    1 +
 include/asm-nios2/bitops.h |    1 +
 include/asm-ppc/bitops.h   |    2 +
 include/asm-sh/bitops.h    |    2 +
 include/linux/bitops.h     |   45 ++++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 53 insertions(+), 0 deletions(-)
include/asm-i386/bitops.h +1 -0
index b768e20..ac6285a 100644
@@ -349,6 +349,7 @@ static __inline__ int ffs(int x)
 		"1:" : "=r" (r) : "g" (x));
 	return r+1;
 }
+#define ffs
 
 /**
  * hweightN - returns the hamming weight of a N-bit word
include/asm-m68k/bitops.h +1 -0
index 0f9e8ab..e0c35fa 100644
@@ -51,6 +51,7 @@ extern __inline__ int ffs(int x)
 	return r;
 }
 #define __ffs(x) (ffs(x) - 1)
+#define ffs
 
 #endif /* __KERNEL__ */
 
include/asm-nios/bitops.h +1 -0
index 7744212..8315fb7 100644
@@ -33,5 +33,6 @@ 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
 
 #endif /* _ASM_NIOS_BITOPS_H */
include/asm-nios2/bitops.h +1 -0
index e6c1a85..b01a89d 100644
@@ -33,5 +33,6 @@ 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
 
 #endif /* __ASM_NIOS2_BITOPS_H */
include/asm-ppc/bitops.h +2 -0
index daa66cf..9ed2f5d 100644
@@ -178,6 +178,7 @@ static __inline__ int fls(unsigned int x)
 {
 	return __ilog2(x) + 1;
 }
+#define fls
 
 /**
  * fls64 - find last set bit in a 64-bit word
@@ -230,6 +231,7 @@ extern __inline__ int ffs(int x)
 {
 	return __ilog2(x & -x) + 1;
 }
+#define ffs
 
 /*
  * hweightN: returns the hamming weight (i.e. the number
include/asm-sh/bitops.h +2 -0
index 410fba4..95167bd 100644
@@ -146,6 +146,8 @@ static inline int ffs (int x)
 	}
 	return r;
 }
+#define ffs
+
 #endif /* __KERNEL__ */
 
 #endif /* __ASM_SH_BITOPS_H */
include/linux/bitops.h +45 -0

57 lines not on this page · raw message

Signature · 1 line
1.6.0.4
#6 lore raw

PATCH v4 3/4 : Define ffs/fls for all architectures

Dear Simon Kagstrom,

Quoted 12 lines · In message <[email protected]> you 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.

---
ChangeLog:
v2: Unify code style (empty line between ffs/fls)
v3: Move the definition to generic code (Mike Frysinger)

Quoted 8 lines
 include/asm-i386/bitops.h  |    1 +
 include/asm-m68k/bitops.h  |    1 +
 include/asm-nios/bitops.h  |    1 +
 include/asm-nios2/bitops.h |    1 +
 include/asm-ppc/bitops.h   |    2 +
 include/asm-sh/bitops.h    |    2 +
 include/linux/bitops.h     |   45 ++++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 53 insertions(+), 0 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
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
"They that can give up essential liberty to obtain a little temporary
saftey deserve neither liberty not saftey." - Benjamin Franklin, 1759
#7 lore raw

PATCH v4 3/4 : Define ffs/fls for all architectures

Hi Simon,

Quoted 25 lines · On Tuesday 15 September 2009 22:34:43 Wolfgang Denk wrote:

Dear Simon Kagstrom,

Quoted 19 lines · In message <[email protected]> you 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.

---
ChangeLog:
v2: Unify code style (empty line between ffs/fls)
v3: Move the definition to generic code (Mike Frysinger)

 include/asm-i386/bitops.h  |    1 +
 include/asm-m68k/bitops.h  |    1 +
 include/asm-nios/bitops.h  |    1 +
 include/asm-nios2/bitops.h |    1 +
 include/asm-ppc/bitops.h   |    2 +
 include/asm-sh/bitops.h    |    2 +
 include/linux/bitops.h     |   45
Quoted 2 lines

++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 53 insertions(+), 0 deletions(-)

Quoted 1 line

Applied, thanks.

I'm seeing strange problem on some PPC4xx platforms (CFI FLASH driver on Sequoia) with recent U-Boot. Bisecting lead me to this patch. And looking at the PPC implementation, I can see that this can't work:

include/asm-ppc/bitops.h:
@@ -230,6 +231,7 @@ extern __inline__ int ffs(int x)
{
return __ilog2(x & -x) + 1;
}
+#define ffs

So after "ffs()" is define as an inline function, you define it to nothing. I understand that you need a flag for include/linux/bitops.h, to decide if the platform version of this function should be used or the generic version:

include/linux/bitops.h:
+#ifndef ffs
+# define ffs generic_ffs
+#endif

But this only works for platforms which don't supply a platform specific ffs function. One way to solve this would be something like this:

include/asm-ppc/bitops.h:
@@ -230,6 +231,7 @@ extern __inline__ int ffs(int x)
{
return __ilog2(x & -x) + 1;
}
+#define PLATFORM_FFS

include/linux/bitops.h:
+#ifndef PLATFORM_FFS
+# define ffs generic_ffs
+#endif

Perhaps there is an more elegant way to solve this problem. Patches welcome ;)

Thanks.

Cheers,
Stefan

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office at denx.de

#8 lore raw

PATCH v4 3/4 : Define ffs/fls for all architectures

Quoted 16 lines · On Wed, 16 Sep 2009 21:19:03 +0200 Stefan Roese <[email protected]> wrote:

include/asm-ppc/bitops.h:

include/asm-ppc/bitops.h +1 -0
@@ -230,6 +231,7 @@ extern __inline__ int ffs(int x)
 {
 	return __ilog2(x & -x) + 1;
 }
+#define ffs
 

So after "ffs()" is define as an inline function, you define it to nothing. I understand that you need a flag for include/linux/bitops.h, to decide if the platform version of this function should be used or the generic version:

include/linux/bitops.h:

include/linux/bitops.h +3 -0
+#ifndef ffs
+# define ffs generic_ffs
+#endif
Quoted 2 lines

But this only works for platforms which don't supply a platform specific ffs function.

Ah, of course... What did I think of? Time to wear a funny hat I guess...

include/linux/bitops.h static inline unsigned int generic_hweight8(unsigned int w) · line 124

Quoted 13 lines

One way to solve this would be something like this:

include/asm-ppc/bitops.h:

include/asm-ppc/bitops.h +1 -0
@@ -230,6 +231,7 @@ extern __inline__ int ffs(int x)
 {
 	return __ilog2(x & -x) + 1;
 }
+#define PLATFORM_FFS
 

include/linux/bitops.h:

include/linux/bitops.h +3 -0
+#ifndef PLATFORM_FFS
+# define ffs generic_ffs
+#endif

Yes, the patch should have contained something like that. Well, we'll have to cook up a fix for this then. Sorry about that again.

// Simon

#9 lore raw

PATCH v4 3/4 : Define ffs/fls for all architectures

Quoted 9 lines · On Thursday 17 September 2009 08:45:21 Simon Kagstrom wrote:
Quoted 9 lines

One way to solve this would be something like this:

include/asm-ppc/bitops.h:

include/asm-ppc/bitops.h +1 -0
@@ -230,6 +231,7 @@ extern __inline__ int ffs(int x)
 {
 	return __ilog2(x & -x) + 1;
 }
+#define PLATFORM_FFS
 
Quoted 7 lines

include/linux/bitops.h static inline unsigned int generic_hweight8(unsigned int w) · line 124

Quoted 4 lines

include/linux/bitops.h:

include/linux/bitops.h +3 -0
+#ifndef PLATFORM_FFS
+# define ffs generic_ffs
+#endif

Yes, the patch should have contained something like that. Well, we'll have to cook up a fix for this then. Sorry about that again.

Simon, could you do this please?

And btw:

#ifndef __set_bit

# define __set_bit generic_set_bit
#endif

looks fishy too. Please fix this one as well.

Thanks.

Cheers,
Stefan

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office at denx.de

#10 lore raw

PATCH v4 3/4 : Define ffs/fls for all architectures

On Thu, 17 Sep 2009 08:56:08 +0200

Quoted 4 lines
Quoted 2 lines

Yes, the patch should have contained something like that. Well, we'll have to cook up a fix for this then. Sorry about that again.

Simon, could you do this please?

Yes, absolutely. I'll try to have it done by this afternoon.

Quoted 7 lines

And btw:

#ifndef __set_bit

# define __set_bit generic_set_bit
#endif

looks fishy too. Please fix this one as well.

Yes, I know about that issue as well. It will go in the same patch.

// Simon

#11 lore raw

PATCH v4 3/4 : Define ffs/fls for all architectures

Quoted 9 lines · On Thursday 17 September 2009 09:13:48 Simon Kagstrom wrote:
Quoted 4 lines
Quoted 2 lines

Yes, the patch should have contained something like that. Well, we'll have to cook up a fix for this then. Sorry about that again.

Simon, could you do this please?

Yes, absolutely. I'll try to have it done by this afternoon.

Quoted 2 lines

And btw:

Quoted 7 lines
Quoted 5 lines

#ifndef __set_bit

# define __set_bit generic_set_bit
#endif

looks fishy too. Please fix this one as well.

Yes, I know about that issue as well. It will go in the same patch.

Thanks. :)

Cheers,
Stefan

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office at denx.de

#12 lore raw

PATCH v4 4/4 : arm: Define test_and_set_bit and test_and_clear bit for ARM

In reply to Simon Kagstrom

arm: Define test_and_set_bit and test_and_clear bit for ARM

Needed for (e.g.) ubifs support to work.

---
 include/asm-arm/bitops.h |   28 +++++++++++++++++++++++++---
 1 files changed, 25 insertions(+), 3 deletions(-)
include/asm-arm/bitops.h +25 -3
index 854e225..3c7b00c 100644
@@ -17,6 +17,8 @@
 
 #ifdef __KERNEL__
 
+#include <asm/proc/system.h>
+
 #define smp_mb__before_clear_bit()	do { } while (0)
 #define smp_mb__after_clear_bit()	do { } while (0)
 
@@ -37,8 +39,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);
@@ -49,7 +49,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)
 {
@@ -61,6 +71,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)
Signature · 1 line
1.6.0.4
#13 lore raw

PATCH v4 4/4 : arm: Define test_and_set_bit and test_and_clear bit for ARM

Simon,

I found a slight problem with this section of the patch:

include/asm-arm/bitops.h line 21

Quoted 10 lines · Simon Kagstrom
include/asm-arm/bitops.h +2 -0
index 854e225..3c7b00c 100644
@@ -17,6 +17,8 @@
 
 #ifdef __KERNEL__
 
+#include <asm/proc/system.h>
+

It causes a compiler error on the arm926ejs platform:

In file included from cpu.c:34:
/home/justin/git/u-boot/include/asm/system.h: At top level:
/home/justin/git/u-boot/include/asm/system.h:71: error: expected
identifier or '(' before 'asm'

I did some digging, and it looks like set_cr() is implemented by both asm-arm/system.h and asm-arm/proc-armv/system.h. One implements the function as a macro, while the other uses a standard C function, hence the weird error message. The conflict occurs in cpu/arm926ejs/cpu.c.

* cpu.c includes both common.h and asm/system.h
* common.h includes asm/bitops.h, which now includes asm/proc/system.h

There are a few other values that are defined in both files, although they don't seem to cause any problems.

If I comment out one of the two implementations, the code compiles fine. However, I'm not really sure what the correct fix would be. I just wanted to let you know.

-Justin Waters

#14 lore raw

PATCH v4 4/4 : arm: Define test_and_set_bit and test_and_clear bit for ARM

Quoted 31 lines · Justin Waters

Simon,

I found a slight problem with this section of the patch:

include/asm-arm/bitops.h line 21

Quoted 10 lines · Simon Kagstrom
include/asm-arm/bitops.h +2 -0
index 854e225..3c7b00c 100644
@@ -17,6 +17,8 @@
 
 #ifdef __KERNEL__
 
+#include <asm/proc/system.h>
+

It causes a compiler error on the arm926ejs platform:

In file included from cpu.c:34:
/home/justin/git/u-boot/include/asm/system.h: At top level:
/home/justin/git/u-boot/include/asm/system.h:71: error: expected
identifier or '(' before 'asm'

I did some digging, and it looks like set_cr() is implemented by both asm-arm/system.h and asm-arm/proc-armv/system.h. One implements the function as a macro, while the other uses a standard C function, hence the weird error message. The conflict occurs in cpu/arm926ejs/cpu.c.

* cpu.c includes both common.h and asm/system.h
* common.h includes asm/bitops.h, which now includes asm/proc/system.h

Quoted 6 lines

There are a few other values that are defined in both files, although they don't seem to cause any problems.

If I comment out one of the two implementations, the code compiles fine. However, I'm not really sure what the correct fix would be. I just wanted to let you know.

It's corrent and Simon already send the cleanup which is part of the pending arm pull request

Best Regards,
J.

#15 lore raw

PATCH v4 4/4 : arm: Define test_and_set_bit and test_and_clear bit for ARM

In reply to Justin Waters

Hi Justin!

Quoted 21 lines · On Fri, 4 Sep 2009 17:27:59 -0400 Justin Waters <[email protected]>…

I found a slight problem with this section of the patch:

include/asm-arm/bitops.h line 21

Quoted 10 lines · Simon Kagstrom
include/asm-arm/bitops.h +2 -0
index 854e225..3c7b00c 100644
@@ -17,6 +17,8 @@
 
 #ifdef __KERNEL__
 
+#include <asm/proc/system.h>
+

It causes a compiler error on the arm926ejs platform:

In file included from cpu.c:34:
/home/justin/git/u-boot/include/asm/system.h: At top level:
/home/justin/git/u-boot/include/asm/system.h:71: error: expected
identifier or '(' before 'asm'

Quoted 4 lines

I did some digging, and it looks like set_cr() is implemented by both asm-arm/system.h and asm-arm/proc-armv/system.h. One implements the function as a macro, while the other uses a standard C function, hence the weird error message. The conflict occurs in cpu/arm926ejs/cpu.c.

You are right, but I believe this was fixed an earlier patch, "[PATCH] Remove duplicate set_cr" [1], which is in the ARM tree. I guess that one hasn't shown up in Wolfgangs repository yet, so this series must be applied to the ARM tree for now.

Thanks for testing!

// Simon

[1] http://git.denx.de/?p=u-boot/u-boot-arm.git;a=commit;h=f3d4f8870e69e0fd177397778d97d0751bbd020a

#16 lore raw

PATCH v4 4/4 : arm: Define test_and_set_bit and test_and_clear bit for ARM

In reply to Simon Kagstrom

Dear Simon Kagstrom,

Quoted 8 lines · In message <[email protected]> you wrote:

arm: Define test_and_set_bit and test_and_clear bit for ARM

Needed for (e.g.) ubifs support to work.

---
 include/asm-arm/bitops.h |   28 +++++++++++++++++++++++++---
 1 files changed, 25 insertions(+), 3 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 8 lines
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
The so-called "desktop metaphor" of today's workstations  is  instead
an  "airplane-seat"  metaphor.  Anyone who has shuffled a lap full of
papers while seated between two portly passengers will recognize  the
difference -- one can see only a very few things at once.
                                                   - Fred Brooks, Jr.
#17 lore raw

v4 cover : bitops cleanup and fixes

In reply to Simon Kagstrom
Quoted 2 lines · On Mon, 24 Aug 2009 09:06:05 +0200 Simon Kagstrom…

This update to the patch series just cleans up the commit messages to have the comments in the git comments section.

Sorry to ping you all, but are there any more comments on work to be done before this patch series can be accepted? The patches were these:

[PATCH v4 1/4]: Move __set/clear_bit from ubifs.h to bitops.h [PATCH v4 2/4]: arm: Make arm bitops endianness-independent [PATCH v4 3/4]: Define ffs/fls for all architectures
[PATCH v4 4/4]: arm: Define test_and_set_bit and test_and_clear bit for ARM

Thanks,
// Simon

#18 lore raw

v4 cover : bitops cleanup and fixes

Dear Simon Kagstrom,

Quoted 6 lines · In message <[email protected]> you wrote:
Quoted 2 lines · On Mon, 24 Aug 2009 09:06:05 +0200 Simon Kagstrom…

This update to the patch series just cleans up the commit messages to have the comments in the git comments section.

Quoted 7 lines

Sorry to ping you all, but are there any more comments on work to be done before this patch series can be accepted? The patches were these:

[PATCH v4 1/4]: Move __set/clear_bit from ubifs.h to bitops.h [PATCH v4 2/4]: arm: Make arm bitops endianness-independent [PATCH v4 3/4]: Define ffs/fls for all architectures
[PATCH v4 4/4]: arm: Define test_and_set_bit and test_and_clear bit for ARM

I think we're just waiting for an ARM custodian to pick this up.

Best regards,

Wolfgang Denk

Signature · 6 lines
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
At the source of every error which is blamed on the computer you will
find at least two human errors, including the error of blaming it  on
the computer.
#19 lore raw

v4 cover : bitops cleanup and fixes

Quoted 12 lines · Wolfgang Denk

Dear Simon Kagstrom,

Quoted 9 lines · In message <[email protected]> you wrote:
Quoted 2 lines · On Mon, 24 Aug 2009 09:06:05 +0200 Simon Kagstrom…

This update to the patch series just cleans up the commit messages to have the comments in the git comments section.

Sorry to ping you all, but are there any more comments on work to be done before this patch series can be accepted? The patches were these:

Quoted 6 lines
Quoted 4 lines

[PATCH v4 1/4]: Move __set/clear_bit from ubifs.h to bitops.h [PATCH v4 2/4]: arm: Make arm bitops endianness-independent [PATCH v4 3/4]: Define ffs/fls for all architectures
[PATCH v4 4/4]: arm: Define test_and_set_bit and test_and_clear bit for ARM

I think we're just waiting for an ARM custodian to pick this up.

I've already ack the patches at the V2 version so I wait other arch Maintainer comment as it will impact everyone

Best Regards,
J.

#20 lore raw

v4 cover : bitops cleanup and fixes

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 4 lines · In message <[email protected]> you wrote:
Quoted 4 lines
Quoted 4 lines

Sorry to ping you all, but are there any more comments on work to be done before this patch series can be accepted? The patches were these:

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

[PATCH v4 1/4]: Move __set/clear_bit from ubifs.h to bitops.h [PATCH v4 2/4]: arm: Make arm bitops endianness-independent [PATCH v4 3/4]: Define ffs/fls for all architectures
[PATCH v4 4/4]: arm: Define test_and_set_bit and test_and_clear bit for ARM

I think we're just waiting for an ARM custodian to pick this up.

I've already ack the patches at the V2 version so I wait other arch Maintainer comment as it will impact everyone

Just waiting is a reliable way to delay things forever, expecially when you wait without telling that you are waiting, and without actively pinging the parties you exect answers from.

Forget it. I'll take this directly.

Thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
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
No more blah, blah, blah!
	-- Kirk, "Miri", stardate 2713.6
#21 lore raw

v4 cover : bitops cleanup and fixes

Quoted 12 lines · Wolfgang Denk

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 9 lines · In message <[email protected]> you wrote:
Quoted 9 lines
Quoted 8 lines

Sorry to ping you all, but are there any more comments on work to be done before this patch series can be accepted? The patches were these:

[PATCH v4 1/4]: Move __set/clear_bit from ubifs.h to bitops.h [PATCH v4 2/4]: arm: Make arm bitops endianness-independent [PATCH v4 3/4]: Define ffs/fls for all architectures
[PATCH v4 4/4]: arm: Define test_and_set_bit and test_and_clear bit for ARM

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

I think we're just waiting for an ARM custodian to pick this up.

I've already ack the patches at the V2 version so I wait other arch Maintainer comment as it will impact everyone

Just waiting is a reliable way to delay things forever, expecially when you wait without telling that you are waiting, and without actively pinging the parties you exect answers from.

??
I'm not supposed to apply patches that update all arch except if I receive ack for it or most of at least
so I've gave the ack for the arm part and Mike did a comment and no other Maintainer did a comment so how can I applied to patch?

Best Regards,
J.