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