bitops: make asm-generic/bitops/find.h more generic
Subsystems (3)
PATCH 1/2 bitops: make asm-generic/bitops/find.h more generic
asm-generic/bitops/find.h has the extern declarations of find_next_bit() and find_next_zero_bit() and the macro definitions of find_first_bit() and find_first_zero_bit(). It is only usable by the architectures which enables CONFIG_GENERIC_FIND_NEXT_BIT and disables CONFIG_GENERIC_FIND_FIRST_BIT.
x86 and tile enable both CONFIG_GENERIC_FIND_NEXT_BIT and CONFIG_GENERIC_FIND_FIRST_BIT. These architectures cannot include asm-generic/bitops/find.h in their asm/bitops.h. So ifdefed extern declarations of find_first_bit and find_first_zero_bit() are put in linux/bitops.h.
This makes asm-generic/bitops/find.h usable by these architectures and use it. Also this change is needed for the forthcoming duplicated extern declarations cleanup.
--- arch/tile/include/asm/bitops.h | 1 + arch/x86/include/asm/bitops.h | 2 ++ include/asm-generic/bitops/find.h | 25 +++++++++++++++++++++++++ include/linux/bitops.h | 22 ---------------------- 4 files changed, 28 insertions(+), 22 deletions(-)
arch/tile/include/asm/bitops.h +1 -0
@@ -120,6 +120,7 @@ static inline unsigned long __arch_hweight64(__u64 w)#include <asm-generic/bitops/const_hweight.h> #include <asm-generic/bitops/lock.h> +#include <asm-generic/bitops/find.h> #include <asm-generic/bitops/sched.h> #include <asm-generic/bitops/ext2-non-atomic.h> #include <asm-generic/bitops/minix.h>
arch/x86/include/asm/bitops.h +2 -0
@@ -440,6 +440,8 @@ static inline int fls(int x)#ifdef __KERNEL__ +#include <asm-generic/bitops/find.h> +#include <asm-generic/bitops/sched.h> #define ARCH_HAS_FAST_MULTIPLIER 1
include/asm-generic/bitops/find.h +25 -0
@@ -9,7 +9,32 @@ extern unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long size, unsigned long offset);#endif +#ifdef CONFIG_GENERIC_FIND_FIRST_BIT + +/** +* find_first_bit - find the first set bit in a memory region +* @addr: The address to start the search at +* @size: The maximum size to search +* +* Returns the bit number of the first set bit. +*/ +extern unsigned long find_first_bit (const unsigned long *addr, +unsigned long size); + +/** +* find_first_zero_bit - find the first cleared bit in a memory region +* @addr: The address to start the search at +* @size: The maximum size to search +* +* Returns the bit number of the first cleared bit. +*/ +extern unsigned long find_first_zero_bit (const unsigned long *addr, +unsigned long size); +#else /* CONFIG_GENERIC_FIND_FIRST_BIT */ +#define find_first_bit (addr, size) find_next_bit((addr), (size), 0)#define find_first_zero_bit (addr, size) find_next_zero_bit((addr), (size), 0) +#endif /* CONFIG_GENERIC_FIND_FIRST_BIT */ +#endif /*_ASM_GENERIC_BITOPS_FIND_H_ */
include/linux/bitops.h +0 -22
@@ -136,28 +136,6 @@ static inline unsigned long __ffs64(u64 word) }#ifdef __KERNEL__ -#ifdef CONFIG_GENERIC_FIND_FIRST_BIT - -/** -* find_first_bit - find the first set bit in a memory region -* @addr: The address to start the search at -* @size: The maximum size to search -* -* Returns the bit number of the first set bit. -*/ -extern unsigned long find_first_bit (const unsigned long *addr, -unsigned long size); - -/** -* find_first_zero_bit - find the first cleared bit in a memory region -* @addr: The address to start the search at -* @size: The maximum size to search -* -* Returns the bit number of the first cleared bit. -*/ -extern unsigned long find_first_zero_bit (const unsigned long *addr, -unsigned long size); -#endif /* CONFIG_GENERIC_FIND_FIRST_BIT */ #ifdef CONFIG_GENERIC_FIND_LAST_BIT /**
Signature · 1 line
1.7.1.231.gd0b16
PATCH 2/2 bitops: remove duplicated extern declarations
If CONFIG_GENERIC_FIND_NEXT_BIT is enabled, find_next_bit() and find_next_zero_bit() are doubly declared in asm-generic/bitops/find.h and linux/bitops.h.
asm/bitops.h includes asm-generic/bitops/find.h if and only if the architecture enables CONFIG_GENERIC_FIND_NEXT_BIT. And asm/bitops.h is included by linux/bitops.h
So we can just remove the extern declarations of find_next_bit() and find_next_zero_bit() in linux/bitops.h.
Also we can remove unneeded #ifndef CONFIG_GENERIC_FIND_NEXT_BIT in asm-generic/bitops/find.h.
--- include/asm-generic/bitops/find.h | 14 ++++++++++++-- include/linux/bitops.h | 23 ----------------------- 2 files changed, 12 insertions(+), 25 deletions(-)
include/asm-generic/bitops/find.h +12 -2
@@ -1,13 +1,23 @@#ifndef _ASM_GENERIC_BITOPS_FIND_H_#define _ASM_GENERIC_BITOPS_FIND_H_ -#ifndef CONFIG_GENERIC_FIND_NEXT_BIT +/** +* find_next_bit - find the next set bit in a memory region +* @addr: The address to base the search on +* @offset: The bitnumber to start searching at +* @size: The bitmap size in bits +*/ extern unsigned long find_next_bit (const unsigned long *addr,unsigned long size,unsigned long offset); +/** +* find_next_zero_bit - find the next cleared bit in a memory region +* @addr: The address to base the search on +* @offset: The bitnumber to start searching at +* @size: The bitmap size in bits +*/ extern unsigned long find_next_zero_bit (const unsigned long *addr,unsigned long size,unsigned long offset); -#endif #ifdef CONFIG_GENERIC_FIND_FIRST_BIT
include/linux/bitops.h +0 -23
@@ -149,28 +149,5 @@ extern unsigned long find_last_bit(const unsigned long *addr, unsigned long size);#endif /* CONFIG_GENERIC_FIND_LAST_BIT */ -#ifdef CONFIG_GENERIC_FIND_NEXT_BIT - -/** -* find_next_bit - find the next set bit in a memory region -* @addr: The address to base the search on -* @offset: The bitnumber to start searching at -* @size: The bitmap size in bits -*/ -extern unsigned long find_next_bit (const unsigned long *addr, -unsigned long size,unsigned long offset); - -/** -* find_next_zero_bit - find the next cleared bit in a memory region -* @addr: The address to base the search on -* @offset: The bitnumber to start searching at -* @size: The bitmap size in bits -*/ - -extern unsigned long find_next_zero_bit (const unsigned long *addr, -unsigned long size, -unsigned long offset); - -#endif /* CONFIG_GENERIC_FIND_NEXT_BIT */ #endif /* __KERNEL__ */ #endif
Signature · 1 line
1.7.1.231.gd0b16
Quoted 12 lines · Akinobu Mita
asm-generic/bitops/find.hhas the extern declarations offind_next_bit()andfind_next_zero_bit()and the macro definitions offind_first_bit()andfind_first_zero_bit(). It is only usable by the architectures which enablesCONFIG_GENERIC_FIND_NEXT_BITand disablesCONFIG_GENERIC_FIND_FIRST_BIT.x86 and tile enable both
CONFIG_GENERIC_FIND_NEXT_BITandCONFIG_GENERIC_FIND_FIRST_BIT. These architectures cannot includeasm-generic/bitops/find.hin theirasm/bitops.h. So ifdefed extern declarations offind_first_bitandfind_first_zero_bit()are put inlinux/bitops.h.
Quoted 3 lines
This makes
asm-generic/bitops/find.husable by these architectures and use it. Also this change is needed for the forthcoming duplicated extern declarations cleanup.
This looks good, thanks.
Signature · 2 lines
Chris Metcalf, Tilera Corp. http://www.tilera.com