Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Akinobu Mita | c7f612c | 2006-03-26 01:39:11 -0800 | [diff] [blame] | 2 | #ifndef _ASM_GENERIC_BITOPS_FIND_H_ |
| 3 | #define _ASM_GENERIC_BITOPS_FIND_H_ |
| 4 | |
Akinobu Mita | 19de85e | 2011-05-26 16:26:09 -0700 | [diff] [blame] | 5 | #ifndef find_next_bit |
Akinobu Mita | d852a6a | 2010-09-29 18:08:51 +0900 | [diff] [blame] | 6 | /** |
| 7 | * find_next_bit - find the next set bit in a memory region |
| 8 | * @addr: The address to base the search on |
| 9 | * @offset: The bitnumber to start searching at |
| 10 | * @size: The bitmap size in bits |
Cody P Schafer | ec778ed | 2013-11-12 15:09:48 -0800 | [diff] [blame] | 11 | * |
| 12 | * Returns the bit number for the next set bit |
| 13 | * If no bits are set, returns @size. |
Akinobu Mita | d852a6a | 2010-09-29 18:08:51 +0900 | [diff] [blame] | 14 | */ |
Akinobu Mita | c7f612c | 2006-03-26 01:39:11 -0800 | [diff] [blame] | 15 | extern unsigned long find_next_bit(const unsigned long *addr, unsigned long |
| 16 | size, unsigned long offset); |
Akinobu Mita | 19de85e | 2011-05-26 16:26:09 -0700 | [diff] [blame] | 17 | #endif |
Akinobu Mita | c7f612c | 2006-03-26 01:39:11 -0800 | [diff] [blame] | 18 | |
Clement Courbet | 0ade34c | 2018-02-06 15:38:34 -0800 | [diff] [blame] | 19 | #ifndef find_next_and_bit |
| 20 | /** |
| 21 | * find_next_and_bit - find the next set bit in both memory regions |
| 22 | * @addr1: The first address to base the search on |
| 23 | * @addr2: The second address to base the search on |
| 24 | * @offset: The bitnumber to start searching at |
| 25 | * @size: The bitmap size in bits |
| 26 | * |
| 27 | * Returns the bit number for the next set bit |
| 28 | * If no bits are set, returns @size. |
| 29 | */ |
| 30 | extern unsigned long find_next_and_bit(const unsigned long *addr1, |
| 31 | const unsigned long *addr2, unsigned long size, |
| 32 | unsigned long offset); |
| 33 | #endif |
| 34 | |
Akinobu Mita | 19de85e | 2011-05-26 16:26:09 -0700 | [diff] [blame] | 35 | #ifndef find_next_zero_bit |
Akinobu Mita | d852a6a | 2010-09-29 18:08:51 +0900 | [diff] [blame] | 36 | /** |
| 37 | * find_next_zero_bit - find the next cleared bit in a memory region |
| 38 | * @addr: The address to base the search on |
| 39 | * @offset: The bitnumber to start searching at |
| 40 | * @size: The bitmap size in bits |
Cody P Schafer | ec778ed | 2013-11-12 15:09:48 -0800 | [diff] [blame] | 41 | * |
| 42 | * Returns the bit number of the next zero bit |
| 43 | * If no bits are zero, returns @size. |
Akinobu Mita | d852a6a | 2010-09-29 18:08:51 +0900 | [diff] [blame] | 44 | */ |
Akinobu Mita | c7f612c | 2006-03-26 01:39:11 -0800 | [diff] [blame] | 45 | extern unsigned long find_next_zero_bit(const unsigned long *addr, unsigned |
| 46 | long size, unsigned long offset); |
Akinobu Mita | 19de85e | 2011-05-26 16:26:09 -0700 | [diff] [blame] | 47 | #endif |
Akinobu Mita | c7f612c | 2006-03-26 01:39:11 -0800 | [diff] [blame] | 48 | |
Akinobu Mita | 708ff2a | 2010-09-29 18:08:50 +0900 | [diff] [blame] | 49 | #ifdef CONFIG_GENERIC_FIND_FIRST_BIT |
| 50 | |
| 51 | /** |
| 52 | * find_first_bit - find the first set bit in a memory region |
| 53 | * @addr: The address to start the search at |
Cody P Schafer | ec778ed | 2013-11-12 15:09:48 -0800 | [diff] [blame] | 54 | * @size: The maximum number of bits to search |
Akinobu Mita | 708ff2a | 2010-09-29 18:08:50 +0900 | [diff] [blame] | 55 | * |
| 56 | * Returns the bit number of the first set bit. |
Cody P Schafer | ec778ed | 2013-11-12 15:09:48 -0800 | [diff] [blame] | 57 | * If no bits are set, returns @size. |
Akinobu Mita | 708ff2a | 2010-09-29 18:08:50 +0900 | [diff] [blame] | 58 | */ |
| 59 | extern unsigned long find_first_bit(const unsigned long *addr, |
| 60 | unsigned long size); |
| 61 | |
| 62 | /** |
| 63 | * find_first_zero_bit - find the first cleared bit in a memory region |
| 64 | * @addr: The address to start the search at |
Cody P Schafer | ec778ed | 2013-11-12 15:09:48 -0800 | [diff] [blame] | 65 | * @size: The maximum number of bits to search |
Akinobu Mita | 708ff2a | 2010-09-29 18:08:50 +0900 | [diff] [blame] | 66 | * |
| 67 | * Returns the bit number of the first cleared bit. |
Cody P Schafer | ec778ed | 2013-11-12 15:09:48 -0800 | [diff] [blame] | 68 | * If no bits are zero, returns @size. |
Akinobu Mita | 708ff2a | 2010-09-29 18:08:50 +0900 | [diff] [blame] | 69 | */ |
| 70 | extern unsigned long find_first_zero_bit(const unsigned long *addr, |
| 71 | unsigned long size); |
| 72 | #else /* CONFIG_GENERIC_FIND_FIRST_BIT */ |
| 73 | |
Clement Courbet | 0ade34c | 2018-02-06 15:38:34 -0800 | [diff] [blame] | 74 | #ifndef find_first_bit |
Akinobu Mita | c7f612c | 2006-03-26 01:39:11 -0800 | [diff] [blame] | 75 | #define find_first_bit(addr, size) find_next_bit((addr), (size), 0) |
Clement Courbet | 0ade34c | 2018-02-06 15:38:34 -0800 | [diff] [blame] | 76 | #endif |
| 77 | #ifndef find_first_zero_bit |
Akinobu Mita | c7f612c | 2006-03-26 01:39:11 -0800 | [diff] [blame] | 78 | #define find_first_zero_bit(addr, size) find_next_zero_bit((addr), (size), 0) |
Clement Courbet | 0ade34c | 2018-02-06 15:38:34 -0800 | [diff] [blame] | 79 | #endif |
Akinobu Mita | c7f612c | 2006-03-26 01:39:11 -0800 | [diff] [blame] | 80 | |
Akinobu Mita | 708ff2a | 2010-09-29 18:08:50 +0900 | [diff] [blame] | 81 | #endif /* CONFIG_GENERIC_FIND_FIRST_BIT */ |
| 82 | |
Akinobu Mita | c7f612c | 2006-03-26 01:39:11 -0800 | [diff] [blame] | 83 | #endif /*_ASM_GENERIC_BITOPS_FIND_H_ */ |