18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef _TOOLS_LINUX_ASM_GENERIC_BITOPS_FIND_H_
38c2ecf20Sopenharmony_ci#define _TOOLS_LINUX_ASM_GENERIC_BITOPS_FIND_H_
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#ifndef find_next_bit
68c2ecf20Sopenharmony_ci/**
78c2ecf20Sopenharmony_ci * find_next_bit - find the next set bit in a memory region
88c2ecf20Sopenharmony_ci * @addr: The address to base the search on
98c2ecf20Sopenharmony_ci * @offset: The bitnumber to start searching at
108c2ecf20Sopenharmony_ci * @size: The bitmap size in bits
118c2ecf20Sopenharmony_ci *
128c2ecf20Sopenharmony_ci * Returns the bit number for the next set bit
138c2ecf20Sopenharmony_ci * If no bits are set, returns @size.
148c2ecf20Sopenharmony_ci */
158c2ecf20Sopenharmony_ciextern unsigned long find_next_bit(const unsigned long *addr, unsigned long
168c2ecf20Sopenharmony_ci		size, unsigned long offset);
178c2ecf20Sopenharmony_ci#endif
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#ifndef find_next_and_bit
208c2ecf20Sopenharmony_ci/**
218c2ecf20Sopenharmony_ci * find_next_and_bit - find the next set bit in both memory regions
228c2ecf20Sopenharmony_ci * @addr1: The first address to base the search on
238c2ecf20Sopenharmony_ci * @addr2: The second address to base the search on
248c2ecf20Sopenharmony_ci * @offset: The bitnumber to start searching at
258c2ecf20Sopenharmony_ci * @size: The bitmap size in bits
268c2ecf20Sopenharmony_ci *
278c2ecf20Sopenharmony_ci * Returns the bit number for the next set bit
288c2ecf20Sopenharmony_ci * If no bits are set, returns @size.
298c2ecf20Sopenharmony_ci */
308c2ecf20Sopenharmony_ciextern unsigned long find_next_and_bit(const unsigned long *addr1,
318c2ecf20Sopenharmony_ci		const unsigned long *addr2, unsigned long size,
328c2ecf20Sopenharmony_ci		unsigned long offset);
338c2ecf20Sopenharmony_ci#endif
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci#ifndef find_next_zero_bit
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci/**
388c2ecf20Sopenharmony_ci * find_next_zero_bit - find the next cleared bit in a memory region
398c2ecf20Sopenharmony_ci * @addr: The address to base the search on
408c2ecf20Sopenharmony_ci * @offset: The bitnumber to start searching at
418c2ecf20Sopenharmony_ci * @size: The bitmap size in bits
428c2ecf20Sopenharmony_ci *
438c2ecf20Sopenharmony_ci * Returns the bit number of the next zero bit
448c2ecf20Sopenharmony_ci * If no bits are zero, returns @size.
458c2ecf20Sopenharmony_ci */
468c2ecf20Sopenharmony_ciunsigned long find_next_zero_bit(const unsigned long *addr, unsigned long size,
478c2ecf20Sopenharmony_ci				 unsigned long offset);
488c2ecf20Sopenharmony_ci#endif
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci#ifndef find_first_bit
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci/**
538c2ecf20Sopenharmony_ci * find_first_bit - find the first set bit in a memory region
548c2ecf20Sopenharmony_ci * @addr: The address to start the search at
558c2ecf20Sopenharmony_ci * @size: The maximum number of bits to search
568c2ecf20Sopenharmony_ci *
578c2ecf20Sopenharmony_ci * Returns the bit number of the first set bit.
588c2ecf20Sopenharmony_ci * If no bits are set, returns @size.
598c2ecf20Sopenharmony_ci */
608c2ecf20Sopenharmony_ciextern unsigned long find_first_bit(const unsigned long *addr,
618c2ecf20Sopenharmony_ci				    unsigned long size);
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci#endif /* find_first_bit */
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci#ifndef find_first_zero_bit
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci/**
688c2ecf20Sopenharmony_ci * find_first_zero_bit - find the first cleared bit in a memory region
698c2ecf20Sopenharmony_ci * @addr: The address to start the search at
708c2ecf20Sopenharmony_ci * @size: The maximum number of bits to search
718c2ecf20Sopenharmony_ci *
728c2ecf20Sopenharmony_ci * Returns the bit number of the first cleared bit.
738c2ecf20Sopenharmony_ci * If no bits are zero, returns @size.
748c2ecf20Sopenharmony_ci */
758c2ecf20Sopenharmony_ciunsigned long find_first_zero_bit(const unsigned long *addr, unsigned long size);
768c2ecf20Sopenharmony_ci#endif
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci#endif /*_TOOLS_LINUX_ASM_GENERIC_BITOPS_FIND_H_ */
79