blob: 1ba611e16fa0c2b1ff2ff9b2fff5570564016d3d [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Akinobu Mitac7f612c2006-03-26 01:39:11 -08002#ifndef _ASM_GENERIC_BITOPS_FIND_H_
3#define _ASM_GENERIC_BITOPS_FIND_H_
4
Akinobu Mita19de85e2011-05-26 16:26:09 -07005#ifndef find_next_bit
Akinobu Mitad852a6a2010-09-29 18:08:51 +09006/**
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 Schaferec778ed2013-11-12 15:09:48 -080011 *
12 * Returns the bit number for the next set bit
13 * If no bits are set, returns @size.
Akinobu Mitad852a6a2010-09-29 18:08:51 +090014 */
Akinobu Mitac7f612c2006-03-26 01:39:11 -080015extern unsigned long find_next_bit(const unsigned long *addr, unsigned long
16 size, unsigned long offset);
Akinobu Mita19de85e2011-05-26 16:26:09 -070017#endif
Akinobu Mitac7f612c2006-03-26 01:39:11 -080018
Akinobu Mita19de85e2011-05-26 16:26:09 -070019#ifndef find_next_zero_bit
Akinobu Mitad852a6a2010-09-29 18:08:51 +090020/**
21 * find_next_zero_bit - find the next cleared bit in a memory region
22 * @addr: The address to base the search on
23 * @offset: The bitnumber to start searching at
24 * @size: The bitmap size in bits
Cody P Schaferec778ed2013-11-12 15:09:48 -080025 *
26 * Returns the bit number of the next zero bit
27 * If no bits are zero, returns @size.
Akinobu Mitad852a6a2010-09-29 18:08:51 +090028 */
Akinobu Mitac7f612c2006-03-26 01:39:11 -080029extern unsigned long find_next_zero_bit(const unsigned long *addr, unsigned
30 long size, unsigned long offset);
Akinobu Mita19de85e2011-05-26 16:26:09 -070031#endif
Akinobu Mitac7f612c2006-03-26 01:39:11 -080032
Akinobu Mita708ff2a2010-09-29 18:08:50 +090033#ifdef CONFIG_GENERIC_FIND_FIRST_BIT
34
35/**
36 * find_first_bit - find the first set bit in a memory region
37 * @addr: The address to start the search at
Cody P Schaferec778ed2013-11-12 15:09:48 -080038 * @size: The maximum number of bits to search
Akinobu Mita708ff2a2010-09-29 18:08:50 +090039 *
40 * Returns the bit number of the first set bit.
Cody P Schaferec778ed2013-11-12 15:09:48 -080041 * If no bits are set, returns @size.
Akinobu Mita708ff2a2010-09-29 18:08:50 +090042 */
43extern unsigned long find_first_bit(const unsigned long *addr,
44 unsigned long size);
45
46/**
47 * find_first_zero_bit - find the first cleared bit in a memory region
48 * @addr: The address to start the search at
Cody P Schaferec778ed2013-11-12 15:09:48 -080049 * @size: The maximum number of bits to search
Akinobu Mita708ff2a2010-09-29 18:08:50 +090050 *
51 * Returns the bit number of the first cleared bit.
Cody P Schaferec778ed2013-11-12 15:09:48 -080052 * If no bits are zero, returns @size.
Akinobu Mita708ff2a2010-09-29 18:08:50 +090053 */
54extern unsigned long find_first_zero_bit(const unsigned long *addr,
55 unsigned long size);
56#else /* CONFIG_GENERIC_FIND_FIRST_BIT */
57
Akinobu Mitac7f612c2006-03-26 01:39:11 -080058#define find_first_bit(addr, size) find_next_bit((addr), (size), 0)
59#define find_first_zero_bit(addr, size) find_next_zero_bit((addr), (size), 0)
60
Akinobu Mita708ff2a2010-09-29 18:08:50 +090061#endif /* CONFIG_GENERIC_FIND_FIRST_BIT */
62
Akinobu Mitac7f612c2006-03-26 01:39:11 -080063#endif /*_ASM_GENERIC_BITOPS_FIND_H_ */