Skip to content

Commit

Permalink
bitops: make asm-generic/bitops/find.h more generic
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Cc: Chris Metcalf <cmetcalf@tilera.com>
  • Loading branch information
Akinobu Mita authored and Arnd Bergmann committed Oct 9, 2010
1 parent c24cef0 commit 708ff2a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 22 deletions.
1 change: 1 addition & 0 deletions arch/tile/include/asm/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 2 additions & 0 deletions arch/x86/include/asm/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 25 additions & 0 deletions include/asm-generic/bitops/find.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_ */
22 changes: 0 additions & 22 deletions include/linux/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
/**
Expand Down

0 comments on commit 708ff2a

Please sign in to comment.