1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */ 2*4882a593Smuzhiyun #ifndef _ASM_GENERIC_BITOPS_FIND_H_ 3*4882a593Smuzhiyun #define _ASM_GENERIC_BITOPS_FIND_H_ 4*4882a593Smuzhiyun 5*4882a593Smuzhiyun #ifndef find_next_bit 6*4882a593Smuzhiyun /** 7*4882a593Smuzhiyun * find_next_bit - find the next set bit in a memory region 8*4882a593Smuzhiyun * @addr: The address to base the search on 9*4882a593Smuzhiyun * @offset: The bitnumber to start searching at 10*4882a593Smuzhiyun * @size: The bitmap size in bits 11*4882a593Smuzhiyun * 12*4882a593Smuzhiyun * Returns the bit number for the next set bit 13*4882a593Smuzhiyun * If no bits are set, returns @size. 14*4882a593Smuzhiyun */ 15*4882a593Smuzhiyun extern unsigned long find_next_bit(const unsigned long *addr, unsigned long 16*4882a593Smuzhiyun size, unsigned long offset); 17*4882a593Smuzhiyun #endif 18*4882a593Smuzhiyun 19*4882a593Smuzhiyun #ifndef find_next_and_bit 20*4882a593Smuzhiyun /** 21*4882a593Smuzhiyun * find_next_and_bit - find the next set bit in both memory regions 22*4882a593Smuzhiyun * @addr1: The first address to base the search on 23*4882a593Smuzhiyun * @addr2: The second address to base the search on 24*4882a593Smuzhiyun * @offset: The bitnumber to start searching at 25*4882a593Smuzhiyun * @size: The bitmap size in bits 26*4882a593Smuzhiyun * 27*4882a593Smuzhiyun * Returns the bit number for the next set bit 28*4882a593Smuzhiyun * If no bits are set, returns @size. 29*4882a593Smuzhiyun */ 30*4882a593Smuzhiyun extern unsigned long find_next_and_bit(const unsigned long *addr1, 31*4882a593Smuzhiyun const unsigned long *addr2, unsigned long size, 32*4882a593Smuzhiyun unsigned long offset); 33*4882a593Smuzhiyun #endif 34*4882a593Smuzhiyun 35*4882a593Smuzhiyun #ifndef find_next_zero_bit 36*4882a593Smuzhiyun /** 37*4882a593Smuzhiyun * find_next_zero_bit - find the next cleared bit in a memory region 38*4882a593Smuzhiyun * @addr: The address to base the search on 39*4882a593Smuzhiyun * @offset: The bitnumber to start searching at 40*4882a593Smuzhiyun * @size: The bitmap size in bits 41*4882a593Smuzhiyun * 42*4882a593Smuzhiyun * Returns the bit number of the next zero bit 43*4882a593Smuzhiyun * If no bits are zero, returns @size. 44*4882a593Smuzhiyun */ 45*4882a593Smuzhiyun extern unsigned long find_next_zero_bit(const unsigned long *addr, unsigned 46*4882a593Smuzhiyun long size, unsigned long offset); 47*4882a593Smuzhiyun #endif 48*4882a593Smuzhiyun 49*4882a593Smuzhiyun #ifdef CONFIG_GENERIC_FIND_FIRST_BIT 50*4882a593Smuzhiyun 51*4882a593Smuzhiyun /** 52*4882a593Smuzhiyun * find_first_bit - find the first set bit in a memory region 53*4882a593Smuzhiyun * @addr: The address to start the search at 54*4882a593Smuzhiyun * @size: The maximum number of bits to search 55*4882a593Smuzhiyun * 56*4882a593Smuzhiyun * Returns the bit number of the first set bit. 57*4882a593Smuzhiyun * If no bits are set, returns @size. 58*4882a593Smuzhiyun */ 59*4882a593Smuzhiyun extern unsigned long find_first_bit(const unsigned long *addr, 60*4882a593Smuzhiyun unsigned long size); 61*4882a593Smuzhiyun 62*4882a593Smuzhiyun /** 63*4882a593Smuzhiyun * find_first_zero_bit - find the first cleared bit in a memory region 64*4882a593Smuzhiyun * @addr: The address to start the search at 65*4882a593Smuzhiyun * @size: The maximum number of bits to search 66*4882a593Smuzhiyun * 67*4882a593Smuzhiyun * Returns the bit number of the first cleared bit. 68*4882a593Smuzhiyun * If no bits are zero, returns @size. 69*4882a593Smuzhiyun */ 70*4882a593Smuzhiyun extern unsigned long find_first_zero_bit(const unsigned long *addr, 71*4882a593Smuzhiyun unsigned long size); 72*4882a593Smuzhiyun #else /* CONFIG_GENERIC_FIND_FIRST_BIT */ 73*4882a593Smuzhiyun 74*4882a593Smuzhiyun #ifndef find_first_bit 75*4882a593Smuzhiyun #define find_first_bit(addr, size) find_next_bit((addr), (size), 0) 76*4882a593Smuzhiyun #endif 77*4882a593Smuzhiyun #ifndef find_first_zero_bit 78*4882a593Smuzhiyun #define find_first_zero_bit(addr, size) find_next_zero_bit((addr), (size), 0) 79*4882a593Smuzhiyun #endif 80*4882a593Smuzhiyun 81*4882a593Smuzhiyun #endif /* CONFIG_GENERIC_FIND_FIRST_BIT */ 82*4882a593Smuzhiyun 83*4882a593Smuzhiyun /** 84*4882a593Smuzhiyun * find_next_clump8 - find next 8-bit clump with set bits in a memory region 85*4882a593Smuzhiyun * @clump: location to store copy of found clump 86*4882a593Smuzhiyun * @addr: address to base the search on 87*4882a593Smuzhiyun * @size: bitmap size in number of bits 88*4882a593Smuzhiyun * @offset: bit offset at which to start searching 89*4882a593Smuzhiyun * 90*4882a593Smuzhiyun * Returns the bit offset for the next set clump; the found clump value is 91*4882a593Smuzhiyun * copied to the location pointed by @clump. If no bits are set, returns @size. 92*4882a593Smuzhiyun */ 93*4882a593Smuzhiyun extern unsigned long find_next_clump8(unsigned long *clump, 94*4882a593Smuzhiyun const unsigned long *addr, 95*4882a593Smuzhiyun unsigned long size, unsigned long offset); 96*4882a593Smuzhiyun 97*4882a593Smuzhiyun #define find_first_clump8(clump, bits, size) \ 98*4882a593Smuzhiyun find_next_clump8((clump), (bits), (size), 0) 99*4882a593Smuzhiyun 100*4882a593Smuzhiyun #endif /*_ASM_GENERIC_BITOPS_FIND_H_ */ 101