Skip to content

Commit

Permalink
bitops: add #ifndef for each of find bitops
Browse files Browse the repository at this point in the history
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

This adds the #ifndef for each of the find bitops in the generic header
and source files.

Suggested-by: Arnd Bergmann <[email protected]>
Signed-off-by: Akinobu Mita <[email protected]>
Acked-by: Russell King <[email protected]>
Cc: Martin Schwidefsky <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: Greg Ungerer <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
mita authored and torvalds committed May 27, 2011
1 parent a2812e1 commit 19de85e
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/asm-generic/bitops/find.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef _ASM_GENERIC_BITOPS_FIND_H_
#define _ASM_GENERIC_BITOPS_FIND_H_

#ifndef find_next_bit
/**
* find_next_bit - find the next set bit in a memory region
* @addr: The address to base the search on
Expand All @@ -9,7 +10,9 @@
*/
extern unsigned long find_next_bit(const unsigned long *addr, unsigned long
size, unsigned long offset);
#endif

#ifndef find_next_zero_bit
/**
* find_next_zero_bit - find the next cleared bit in a memory region
* @addr: The address to base the search on
Expand All @@ -18,6 +21,7 @@ extern unsigned long find_next_bit(const unsigned long *addr, unsigned long
*/
extern unsigned long find_next_zero_bit(const unsigned long *addr, unsigned
long size, unsigned long offset);
#endif

#ifdef CONFIG_GENERIC_FIND_FIRST_BIT

Expand Down
7 changes: 7 additions & 0 deletions include/asm-generic/bitops/le.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,20 @@ static inline unsigned long find_first_zero_bit_le(const void *addr,

#define BITOP_LE_SWIZZLE ((BITS_PER_LONG-1) & ~0x7)

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

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

#ifndef find_first_zero_bit_le
#define find_first_zero_bit_le(addr, size) \
find_next_zero_bit_le((addr), (size), 0)
#endif

#else
#error "Please fix <asm/byteorder.h>"
Expand Down
2 changes: 2 additions & 0 deletions include/linux/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ static inline unsigned long __ffs64(u64 word)
#ifdef __KERNEL__

#ifdef CONFIG_GENERIC_FIND_LAST_BIT
#ifndef find_last_bit
/**
* find_last_bit - find the last set bit in a memory region
* @addr: The address to start the search at
Expand All @@ -158,6 +159,7 @@ static inline unsigned long __ffs64(u64 word)
*/
extern unsigned long find_last_bit(const unsigned long *addr,
unsigned long size);
#endif
#endif /* CONFIG_GENERIC_FIND_LAST_BIT */

#endif /* __KERNEL__ */
Expand Down
4 changes: 4 additions & 0 deletions lib/find_last_bit.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include <asm/types.h>
#include <asm/byteorder.h>

#ifndef find_last_bit

unsigned long find_last_bit(const unsigned long *addr, unsigned long size)
{
unsigned long words;
Expand Down Expand Up @@ -43,3 +45,5 @@ unsigned long find_last_bit(const unsigned long *addr, unsigned long size)
return size;
}
EXPORT_SYMBOL(find_last_bit);

#endif
12 changes: 12 additions & 0 deletions lib/find_next_bit.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#define BITOP_WORD(nr) ((nr) / BITS_PER_LONG)

#ifdef CONFIG_GENERIC_FIND_NEXT_BIT
#ifndef find_next_bit
/*
* Find the next set bit in a memory region.
*/
Expand Down Expand Up @@ -59,7 +60,9 @@ unsigned long find_next_bit(const unsigned long *addr, unsigned long size,
return result + __ffs(tmp);
}
EXPORT_SYMBOL(find_next_bit);
#endif

#ifndef find_next_zero_bit
/*
* This implementation of find_{first,next}_zero_bit was stolen from
* Linus' asm-alpha/bitops.h.
Expand Down Expand Up @@ -103,9 +106,11 @@ unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long size,
return result + ffz(tmp);
}
EXPORT_SYMBOL(find_next_zero_bit);
#endif
#endif /* CONFIG_GENERIC_FIND_NEXT_BIT */

#ifdef CONFIG_GENERIC_FIND_FIRST_BIT
#ifndef find_first_bit
/*
* Find the first set bit in a memory region.
*/
Expand All @@ -131,7 +136,9 @@ unsigned long find_first_bit(const unsigned long *addr, unsigned long size)
return result + __ffs(tmp);
}
EXPORT_SYMBOL(find_first_bit);
#endif

#ifndef find_first_zero_bit
/*
* Find the first cleared bit in a memory region.
*/
Expand All @@ -157,6 +164,7 @@ unsigned long find_first_zero_bit(const unsigned long *addr, unsigned long size)
return result + ffz(tmp);
}
EXPORT_SYMBOL(find_first_zero_bit);
#endif
#endif /* CONFIG_GENERIC_FIND_FIRST_BIT */

#ifdef __BIG_ENDIAN
Expand Down Expand Up @@ -186,6 +194,7 @@ static inline unsigned long ext2_swab(const unsigned long y)
#endif
}

#ifndef find_next_zero_bit_le
unsigned long find_next_zero_bit_le(const void *addr, unsigned
long size, unsigned long offset)
{
Expand Down Expand Up @@ -229,7 +238,9 @@ unsigned long find_next_zero_bit_le(const void *addr, unsigned
return result + ffz(ext2_swab(tmp));
}
EXPORT_SYMBOL(find_next_zero_bit_le);
#endif

#ifndef find_next_bit_le
unsigned long find_next_bit_le(const void *addr, unsigned
long size, unsigned long offset)
{
Expand Down Expand Up @@ -274,6 +285,7 @@ unsigned long find_next_bit_le(const void *addr, unsigned
return result + __ffs(ext2_swab(tmp));
}
EXPORT_SYMBOL(find_next_bit_le);
#endif

#endif /* CONFIG_GENERIC_FIND_BIT_LE */
#endif /* __BIG_ENDIAN */

0 comments on commit 19de85e

Please sign in to comment.