Akinobu Mita | c7f612c | 2006-03-26 01:39:11 -0800 | [diff] [blame] | 1 | #ifndef _ASM_GENERIC_BITOPS_FIND_H_ |
| 2 | #define _ASM_GENERIC_BITOPS_FIND_H_ |
| 3 | |
Akinobu Mita | 19de85e | 2011-05-26 16:26:09 -0700 | [diff] [blame] | 4 | #ifndef find_next_bit |
Akinobu Mita | d852a6a | 2010-09-29 18:08:51 +0900 | [diff] [blame] | 5 | /** |
| 6 | * find_next_bit - find the next set bit in a memory region |
| 7 | * @addr: The address to base the search on |
| 8 | * @offset: The bitnumber to start searching at |
| 9 | * @size: The bitmap size in bits |
Cody P Schafer | ec778ed | 2013-11-12 15:09:48 -0800 | [diff] [blame^] | 10 | * |
| 11 | * Returns the bit number for the next set bit |
| 12 | * If no bits are set, returns @size. |
Akinobu Mita | d852a6a | 2010-09-29 18:08:51 +0900 | [diff] [blame] | 13 | */ |
Akinobu Mita | c7f612c | 2006-03-26 01:39:11 -0800 | [diff] [blame] | 14 | extern unsigned long find_next_bit(const unsigned long *addr, unsigned long |
| 15 | size, unsigned long offset); |
Akinobu Mita | 19de85e | 2011-05-26 16:26:09 -0700 | [diff] [blame] | 16 | #endif |
Akinobu Mita | c7f612c | 2006-03-26 01:39:11 -0800 | [diff] [blame] | 17 | |
Akinobu Mita | 19de85e | 2011-05-26 16:26:09 -0700 | [diff] [blame] | 18 | #ifndef find_next_zero_bit |
Akinobu Mita | d852a6a | 2010-09-29 18:08:51 +0900 | [diff] [blame] | 19 | /** |
| 20 | * find_next_zero_bit - find the next cleared bit in a memory region |
| 21 | * @addr: The address to base the search on |
| 22 | * @offset: The bitnumber to start searching at |
| 23 | * @size: The bitmap size in bits |
Cody P Schafer | ec778ed | 2013-11-12 15:09:48 -0800 | [diff] [blame^] | 24 | * |
| 25 | * Returns the bit number of the next zero bit |
| 26 | * If no bits are zero, returns @size. |
Akinobu Mita | d852a6a | 2010-09-29 18:08:51 +0900 | [diff] [blame] | 27 | */ |
Akinobu Mita | c7f612c | 2006-03-26 01:39:11 -0800 | [diff] [blame] | 28 | extern unsigned long find_next_zero_bit(const unsigned long *addr, unsigned |
| 29 | long size, unsigned long offset); |
Akinobu Mita | 19de85e | 2011-05-26 16:26:09 -0700 | [diff] [blame] | 30 | #endif |
Akinobu Mita | c7f612c | 2006-03-26 01:39:11 -0800 | [diff] [blame] | 31 | |
Akinobu Mita | 708ff2a | 2010-09-29 18:08:50 +0900 | [diff] [blame] | 32 | #ifdef CONFIG_GENERIC_FIND_FIRST_BIT |
| 33 | |
| 34 | /** |
| 35 | * find_first_bit - find the first set bit in a memory region |
| 36 | * @addr: The address to start the search at |
Cody P Schafer | ec778ed | 2013-11-12 15:09:48 -0800 | [diff] [blame^] | 37 | * @size: The maximum number of bits to search |
Akinobu Mita | 708ff2a | 2010-09-29 18:08:50 +0900 | [diff] [blame] | 38 | * |
| 39 | * Returns the bit number of the first set bit. |
Cody P Schafer | ec778ed | 2013-11-12 15:09:48 -0800 | [diff] [blame^] | 40 | * If no bits are set, returns @size. |
Akinobu Mita | 708ff2a | 2010-09-29 18:08:50 +0900 | [diff] [blame] | 41 | */ |
| 42 | extern unsigned long find_first_bit(const unsigned long *addr, |
| 43 | unsigned long size); |
| 44 | |
| 45 | /** |
| 46 | * find_first_zero_bit - find the first cleared bit in a memory region |
| 47 | * @addr: The address to start the search at |
Cody P Schafer | ec778ed | 2013-11-12 15:09:48 -0800 | [diff] [blame^] | 48 | * @size: The maximum number of bits to search |
Akinobu Mita | 708ff2a | 2010-09-29 18:08:50 +0900 | [diff] [blame] | 49 | * |
| 50 | * Returns the bit number of the first cleared bit. |
Cody P Schafer | ec778ed | 2013-11-12 15:09:48 -0800 | [diff] [blame^] | 51 | * If no bits are zero, returns @size. |
Akinobu Mita | 708ff2a | 2010-09-29 18:08:50 +0900 | [diff] [blame] | 52 | */ |
| 53 | extern unsigned long find_first_zero_bit(const unsigned long *addr, |
| 54 | unsigned long size); |
| 55 | #else /* CONFIG_GENERIC_FIND_FIRST_BIT */ |
| 56 | |
Akinobu Mita | c7f612c | 2006-03-26 01:39:11 -0800 | [diff] [blame] | 57 | #define find_first_bit(addr, size) find_next_bit((addr), (size), 0) |
| 58 | #define find_first_zero_bit(addr, size) find_next_zero_bit((addr), (size), 0) |
| 59 | |
Akinobu Mita | 708ff2a | 2010-09-29 18:08:50 +0900 | [diff] [blame] | 60 | #endif /* CONFIG_GENERIC_FIND_FIRST_BIT */ |
| 61 | |
Akinobu Mita | c7f612c | 2006-03-26 01:39:11 -0800 | [diff] [blame] | 62 | #endif /*_ASM_GENERIC_BITOPS_FIND_H_ */ |