[U-Boot] [PATCH v4 0/4]: 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

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 --- 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(-)
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-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

Dear Simon Kagstrom,
In message 20090824090950.6e3f9601@marrow.netinsight.se 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.
Signed-off-by: Simon Kagstrom simon.kagstrom@netinsight.net
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(-)
Applied, thanks.
Best regards,
Wolfgang Denk

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.
Signed-off-by: Simon Kagstrom simon.kagstrom@netinsight.net --- ChangeLog: v2: Use generic __set_bit and __clear_bit for ARM
include/asm-arm/bitops.h | 47 ++++++++++++++++++--------------------------- 1 files changed, 19 insertions(+), 28 deletions(-)
diff --git a/include/asm-arm/bitops.h b/include/asm-arm/bitops.h index 1549da1..854e225 100644 --- a/include/asm-arm/bitops.h +++ b/include/asm-arm/bitops.h @@ -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);

Dear Simon Kagstrom,
In message 20090824091003.0b8a631f@marrow.netinsight.se 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.
Signed-off-by: Simon Kagstrom simon.kagstrom@netinsight.net
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

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.
Signed-off-by: Simon Kagstrom simon.kagstrom@netinsight.net --- 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(-)
diff --git a/include/asm-i386/bitops.h b/include/asm-i386/bitops.h index b768e20..ac6285a 100644 --- a/include/asm-i386/bitops.h +++ b/include/asm-i386/bitops.h @@ -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 diff --git a/include/asm-m68k/bitops.h b/include/asm-m68k/bitops.h index 0f9e8ab..e0c35fa 100644 --- a/include/asm-m68k/bitops.h +++ b/include/asm-m68k/bitops.h @@ -51,6 +51,7 @@ extern __inline__ int ffs(int x) return r; } #define __ffs(x) (ffs(x) - 1) +#define ffs
#endif /* __KERNEL__ */
diff --git a/include/asm-nios/bitops.h b/include/asm-nios/bitops.h index 7744212..8315fb7 100644 --- a/include/asm-nios/bitops.h +++ b/include/asm-nios/bitops.h @@ -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 */ diff --git a/include/asm-nios2/bitops.h b/include/asm-nios2/bitops.h index e6c1a85..b01a89d 100644 --- a/include/asm-nios2/bitops.h +++ b/include/asm-nios2/bitops.h @@ -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 */ diff --git a/include/asm-ppc/bitops.h b/include/asm-ppc/bitops.h index daa66cf..9ed2f5d 100644 --- a/include/asm-ppc/bitops.h +++ b/include/asm-ppc/bitops.h @@ -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 diff --git a/include/asm-sh/bitops.h b/include/asm-sh/bitops.h index 410fba4..95167bd 100644 --- a/include/asm-sh/bitops.h +++ b/include/asm-sh/bitops.h @@ -146,6 +146,8 @@ static inline int ffs (int x) } return r; } +#define ffs + #endif /* __KERNEL__ */
#endif /* __ASM_SH_BITOPS_H */ diff --git a/include/linux/bitops.h b/include/linux/bitops.h index 387a818..e14e6c7 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -38,6 +38,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 @@ -82,6 +119,14 @@ static inline unsigned int generic_hweight8(unsigned int w) # define __clear_bit generic_clear_bit #endif
+#ifndef ffs +# define ffs generic_ffs +#endif + +#ifndef fls +# define fls generic_fls +#endif + /** * __set_bit - Set a bit in memory * @nr: the bit to set

Dear Simon Kagstrom,
In message 20090824091012.0df5bbff@marrow.netinsight.se 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.
Signed-off-by: Simon Kagstrom simon.kagstrom@netinsight.net
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(-)
Applied, thanks.
Best regards,
Wolfgang Denk

Hi Simon,
On Tuesday 15 September 2009 22:34:43 Wolfgang Denk wrote:
Dear Simon Kagstrom,
In message 20090824091012.0df5bbff@marrow.netinsight.se 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.
Signed-off-by: Simon Kagstrom simon.kagstrom@netinsight.net
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(-)
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@denx.de

On Wed, 16 Sep 2009 21:19:03 +0200 Stefan Roese sr@denx.de wrote:
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.
Ah, of course... What did I think of? Time to wear a funny hat I guess...
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
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

On Thursday 17 September 2009 08:45:21 Simon Kagstrom wrote:
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
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@denx.de

On Thu, 17 Sep 2009 08:56:08 +0200
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.
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

On Thursday 17 September 2009 09:13:48 Simon Kagstrom wrote:
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.
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.
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@denx.de

arm: 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 | 28 +++++++++++++++++++++++++--- 1 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/include/asm-arm/bitops.h b/include/asm-arm/bitops.h index 854e225..3c7b00c 100644 --- a/include/asm-arm/bitops.h +++ b/include/asm-arm/bitops.h @@ -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)

Simon,
I found a slight problem with this section of the patch:
On Mon, 2009-08-24 at 03:10 -0400, Simon Kagstrom wrote:
diff --git a/include/asm-arm/bitops.h b/include/asm-arm/bitops.h index 854e225..3c7b00c 100644 --- a/include/asm-arm/bitops.h +++ b/include/asm-arm/bitops.h @@ -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

On 17:27 Fri 04 Sep , Justin Waters wrote:
Simon,
I found a slight problem with this section of the patch:
On Mon, 2009-08-24 at 03:10 -0400, Simon Kagstrom wrote:
diff --git a/include/asm-arm/bitops.h b/include/asm-arm/bitops.h index 854e225..3c7b00c 100644 --- a/include/asm-arm/bitops.h +++ b/include/asm-arm/bitops.h @@ -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.
It's corrent and Simon already send the cleanup which is part of the pending arm pull request
Best Regards, J.

Hi Justin!
On Fri, 4 Sep 2009 17:27:59 -0400 Justin Waters justin.waters@timesys.com wrote:
I found a slight problem with this section of the patch:
On Mon, 2009-08-24 at 03:10 -0400, Simon Kagstrom wrote:
diff --git a/include/asm-arm/bitops.h b/include/asm-arm/bitops.h index 854e225..3c7b00c 100644 --- a/include/asm-arm/bitops.h +++ b/include/asm-arm/bitops.h @@ -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.
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=f3d4f8870e69e0fd17739...

Dear Simon Kagstrom,
In message 20090824091016.7be37982@marrow.netinsight.se you wrote:
arm: 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 | 28 +++++++++++++++++++++++++--- 1 files changed, 25 insertions(+), 3 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

On Mon, 24 Aug 2009 09:06:05 +0200 Simon Kagstrom simon.kagstrom@netinsight.net wrote:
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

Dear Simon Kagstrom,
In message 20090831113210.02299c7a@marrow.netinsight.se you wrote:
On Mon, 24 Aug 2009 09:06:05 +0200 Simon Kagstrom simon.kagstrom@netinsight.net wrote:
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
I think we're just waiting for an ARM custodian to pick this up.
Best regards,
Wolfgang Denk

On 22:14 Fri 04 Sep , Wolfgang Denk wrote:
Dear Simon Kagstrom,
In message 20090831113210.02299c7a@marrow.netinsight.se you wrote:
On Mon, 24 Aug 2009 09:06:05 +0200 Simon Kagstrom simon.kagstrom@netinsight.net wrote:
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
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.

Dear Jean-Christophe PLAGNIOL-VILLARD,
In message 20090905113728.GN30118@game.jcrosoft.org you wrote:
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.
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

On 22:50 Sun 06 Sep , Wolfgang Denk wrote:
Dear Jean-Christophe PLAGNIOL-VILLARD,
In message 20090905113728.GN30118@game.jcrosoft.org you wrote:
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.
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.
participants (5)
-
Jean-Christophe PLAGNIOL-VILLARD
-
Justin Waters
-
Simon Kagstrom
-
Stefan Roese
-
Wolfgang Denk