Skip to contentSkip to conversation

bitops: add ifdef CONFIG_GENERIC_FIND_BIT_LE guard

PATCH In review Akinobu Mita 2 participants 6 messages Apr 20, 2011 – Apr 21, 2011

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

PATCH 1/3 bitops: add ifdef CONFIG_GENERIC_FIND_BIT_LE guard

Some architectures have optimized find_*_bit_le() as static inline functions but other little-endian bitops are identical to the generic version.

This adds #ifdef CONFIG_GENERIC_FIND_BIT_LE guard for find_*_bit_le() in asm-generic/bitops/le.h so that those architectures can use this header file.

Cc Arnd Bergmann <[email protected]>
Cc linux-arch at vger.kernel.org
Cc Martin Schwidefsky <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc linux390 at de.ibm.com
Cc linux-s390 at vger.kernel.org
Cc Russell King <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
---
 include/asm-generic/bitops/le.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
include/asm-generic/bitops/le.h +4 -0
index 946a21b..bd2253e 100644
@@ -30,6 +30,8 @@ static inline unsigned long find_first_zero_bit_le(const void *addr,
 
 #define BITOP_LE_SWIZZLE	((BITS_PER_LONG-1) & ~0x7)
 
+#ifdef CONFIG_GENERIC_FIND_BIT_LE
+
 extern unsigned long find_next_zero_bit_le(const void *addr,
 		unsigned long size, unsigned long offset);
 extern unsigned long find_next_bit_le(const void *addr,
@@ -38,6 +40,8 @@ extern unsigned long find_next_bit_le(const void *addr,
 #define find_first_zero_bit_le(addr, size) \
 	find_next_zero_bit_le((addr), (size), 0)
 
+#endif /* CONFIG_GENERIC_FIND_BIT_LE */
+
 #else
 #error "Please fix <asm/byteorder.h>"
 #endif
Signature · 1 line
1.7.4.4
#1 lore raw

PATCH 2/3 arm: use asm-generic/bitops/le.h

The previous change enables to use asm-generic/bitops/le.h on arm.

Cc Russell King <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
---
 arch/arm/include/asm/bitops.h |   41 ++++-------------------------------------
 1 files changed, 4 insertions(+), 37 deletions(-)
arch/arm/include/asm/bitops.h +4 -37
index ec2e0d4..4615e1b 100644
@@ -203,8 +203,6 @@ extern int _find_next_bit_be(const unsigned long *p, int size, int offset);
 #define find_first_bit(p,sz)		_find_first_bit_le(p,sz)
 #define find_next_bit(p,sz,off)		_find_next_bit_le(p,sz,off)
 
-#define WORD_BITOFF_TO_LE(x)		((x))
-
 #else
 /*
  * These are the big endian, atomic definitions.
@@ -214,8 +212,6 @@ extern int _find_next_bit_be(const unsigned long *p, int size, int offset);
 #define find_first_bit(p,sz)		_find_first_bit_be(p,sz)
 #define find_next_bit(p,sz,off)		_find_next_bit_be(p,sz,off)
 
-#define WORD_BITOFF_TO_LE(x)		((x) ^ 0x18)
-
 #endif
 
 #if __LINUX_ARM_ARCH__ < 5
@@ -287,40 +283,9 @@ static inline int fls(int x)
 #include <asm-generic/bitops/hweight.h>
 #include <asm-generic/bitops/lock.h>
 
-static inline void __set_bit_le(int nr, void *addr)
-{
-	__set_bit(WORD_BITOFF_TO_LE(nr), addr);
-}
-
-static inline void __clear_bit_le(int nr, void *addr)
-{
-	__clear_bit(WORD_BITOFF_TO_LE(nr), addr);
-}
-
-static inline int __test_and_set_bit_le(int nr, void *addr)
-{
-	return __test_and_set_bit(WORD_BITOFF_TO_LE(nr), addr);
-}
+#include <asm-generic/bitops/le.h>
 
-static inline int test_and_set_bit_le(int nr, void *addr)
-{
-	return test_and_set_bit(WORD_BITOFF_TO_LE(nr), addr);
-}
-
-static inline int __test_and_clear_bit_le(int nr, void *addr)
-{
-	return __test_and_clear_bit(WORD_BITOFF_TO_LE(nr), addr);
-}
-
-static inline int test_and_clear_bit_le(int nr, void *addr)
-{
-	return test_and_clear_bit(WORD_BITOFF_TO_LE(nr), addr);
-}
-
-static inline int test_bit_le(int nr, const void *addr)
-{
-	return test_bit(WORD_BITOFF_TO_LE(nr), addr);
-}
+#ifdef __ARMEB__
 
 static inline int find_first_zero_bit_le(const void *p, unsigned size)
 {
@@ -337,6 +302,8 @@ static inline int find_next_bit_le(const void *p, int size, int offset)
 	return _find_next_bit_le(p, size, offset);
 }
 
+#endif
+
 /*
  * Ext2 is defined to use little-endian byte ordering.
  */
Signature · 1 line
1.7.4.4
#2 lore raw

PATCH 3/3 s390: use asm-generic/bitops/le.h

In reply to Akinobu Mita

The previous change enables to use asm-generic/bitops/le.h on s390.

---
 arch/s390/include/asm/bitops.h |   35 +----------------------------------
 1 files changed, 1 insertions(+), 34 deletions(-)
arch/s390/include/asm/bitops.h +1 -34
index 38fab08..8a54b41 100644
@@ -742,40 +742,7 @@ static inline int sched_find_first_bit(unsigned long *b)
  *    23 22 21 20 19 18 17 16 31 30 29 28 27 26 25 24
  */
 
-static inline void __set_bit_le(unsigned long nr, void *addr)
-{
-	__set_bit(nr ^ (__BITOPS_WORDSIZE - 8), addr);
-}
-
-static inline void __clear_bit_le(unsigned long nr, void *addr)
-{
-	__clear_bit(nr ^ (__BITOPS_WORDSIZE - 8), addr);
-}
-
-static inline int __test_and_set_bit_le(unsigned long nr, void *addr)
-{
-	return __test_and_set_bit(nr ^ (__BITOPS_WORDSIZE - 8), addr);
-}
-
-static inline int test_and_set_bit_le(unsigned long nr, void *addr)
-{
-	return test_and_set_bit(nr ^ (__BITOPS_WORDSIZE - 8), addr);
-}
-
-static inline int __test_and_clear_bit_le(unsigned long nr, void *addr)
-{
-	return __test_and_clear_bit(nr ^ (__BITOPS_WORDSIZE - 8), addr);
-}
-
-static inline int test_and_clear_bit_le(unsigned long nr, void *addr)
-{
-	return test_and_clear_bit(nr ^ (__BITOPS_WORDSIZE - 8), addr);
-}
-
-static inline int test_bit_le(unsigned long nr, const void *addr)
-{
-	return test_bit(nr ^ (__BITOPS_WORDSIZE - 8), addr);
-}
+#include <asm-generic/bitops/le.h>
 
 static inline int find_first_zero_bit_le(void *vaddr, unsigned int size)
 {
Signature · 1 line
1.7.4.4
maintainer
#3 lore raw
In reply to Akinobu Mita
Quoted 13 lines · Akinobu Mita

index 946a21b..bd2253e 100644

include/asm-generic/bitops/le.h +2 -0
@@ -30,6 +30,8 @@ static inline unsigned long find_first_zero_bit_le(const void *addr,
 
 #define BITOP_LE_SWIZZLE       ((BITS_PER_LONG-1) & ~0x7)
 
+#ifdef CONFIG_GENERIC_FIND_BIT_LE
+
 extern unsigned long find_next_zero_bit_le(const void *addr,
                unsigned long size, unsigned long offset);
 extern unsigned long find_next_bit_le(const void *addr,

include/asm-generic/bitops/le.h extern unsigned long find_next_bit_le(const void *addr, · line 47

Quoted 8 lines
include/asm-generic/bitops/le.h +2 -0
@@ -38,6 +40,8 @@ extern unsigned long find_next_bit_le(const void *addr,
 #define find_first_zero_bit_le(addr, size) \
        find_next_zero_bit_le((addr), (size), 0)
 
+#endif /* CONFIG_GENERIC_FIND_BIT_LE */
+
 #else
 #error "Please fix <asm/byteorder.h>"
 #endif

The style that we normally use in asm-generic is to test the macro itself for existence, so in asm-generic, do:

#ifndef find_next_zero_bit_le
extern unsigned long find_next_zero_bit_le(const void *addr,

                 unsigned long size, unsigned long offset);

#endif

and in the architectures, write

static inline unsigned long find_next_zero_bit_le(const void *addr,
unsigned long size, unsigned long offset)
#define find_next_zero_bit_le find_next_zero_bit_le

I guess we can do the #ifdef separately for each of the three macros, or choose one of them to use as a key.

Arnd

#4 lore raw

2011/4/20 Arnd Bergmann <[email protected]>:

Quoted 31 lines · Akinobu Mita
Quoted 18 lines

index 946a21b..bd2253e 100644

include/asm-generic/bitops/le.h +4 -0
@@ -30,6 +30,8 @@ static inline unsigned long find_first_zero_bit_le(const void *addr,
 
 ?#define BITOP_LE_SWIZZLE ? ? ? ((BITS_PER_LONG-1) & ~0x7)
 
+#ifdef CONFIG_GENERIC_FIND_BIT_LE
+
 ?extern unsigned long find_next_zero_bit_le(const void *addr,
 ? ? ? ? ? ? ? ? unsigned long size, unsigned long offset);
 ?extern unsigned long find_next_bit_le(const void *addr,
@@ -38,6 +40,8 @@ extern unsigned long find_next_bit_le(const void *addr,
 ?#define find_first_zero_bit_le(addr, size) \
 ? ? ? ? find_next_zero_bit_le((addr), (size), 0)
 
+#endif /* CONFIG_GENERIC_FIND_BIT_LE */
+
Quoted 3 lines

?#else
?#error "Please fix <asm/byteorder.h>"
?#endif

The style that we normally use in asm-generic is to test the macro itself for existence, so in asm-generic, do:

#ifndef find_next_zero_bit_le
extern unsigned long find_next_zero_bit_le(const void *addr, ? ? ? ? ? ? ? ? unsigned long size, unsigned long offset); #endif

Quoted 8 lines

and in the architectures, write

static inline unsigned long find_next_zero_bit_le(const void *addr, ? ? ? ? ? ? ? ? unsigned long size, unsigned long offset) #define find_next_zero_bit_le find_next_zero_bit_le

I guess we can do the #ifdef separately for each of the three macros, or choose one of them to use as a key.

I see.

Should we also kill CONFIG_GENERIC_FIND_BIT_LE option comletely, then add the #ifdef for each find_*() in lib/find_next_bit.c and always build it unconditionally ?

maintainer
#5 lore raw
Quoted 3 lines · Akinobu Mita

Should we also kill CONFIG_GENERIC_FIND_BIT_LE option comletely, then add the #ifdef for each find_*() in lib/find_next_bit.c and always build it unconditionally ?

I think that would be more consistent. It's not a big difference anyway, so do it only if you feel motivated. There are a lot of other things that could be changed this way, I'd only change it while reworking other aspects in order to avoid accidentally breaking things.

Arnd