blob: 8a1ee10014def138147395aaf1b5514c5f752e31 [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
Clement Courbet0ade34c2018-02-06 15:38:34 -080019#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 */
30extern 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 Mita19de85e2011-05-26 16:26:09 -070035#ifndef find_next_zero_bit
Akinobu Mitad852a6a2010-09-29 18:08:51 +090036/**
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 Schaferec778ed2013-11-12 15:09:48 -080041 *
42 * Returns the bit number of the next zero bit
43 * If no bits are zero, returns @size.
Akinobu Mitad852a6a2010-09-29 18:08:51 +090044 */
Akinobu Mitac7f612c2006-03-26 01:39:11 -080045extern unsigned long find_next_zero_bit(const unsigned long *addr, unsigned
46 long size, unsigned long offset);
Akinobu Mita19de85e2011-05-26 16:26:09 -070047#endif
Akinobu Mitac7f612c2006-03-26 01:39:11 -080048
Akinobu Mita708ff2a2010-09-29 18:08:50 +090049#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 Schaferec778ed2013-11-12 15:09:48 -080054 * @size: The maximum number of bits to search
Akinobu Mita708ff2a2010-09-29 18:08:50 +090055 *
56 * Returns the bit number of the first set bit.
Cody P Schaferec778ed2013-11-12 15:09:48 -080057 * If no bits are set, returns @size.
Akinobu Mita708ff2a2010-09-29 18:08:50 +090058 */
59extern 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 Schaferec778ed2013-11-12 15:09:48 -080065 * @size: The maximum number of bits to search
Akinobu Mita708ff2a2010-09-29 18:08:50 +090066 *
67 * Returns the bit number of the first cleared bit.
Cody P Schaferec778ed2013-11-12 15:09:48 -080068 * If no bits are zero, returns @size.
Akinobu Mita708ff2a2010-09-29 18:08:50 +090069 */
70extern unsigned long find_first_zero_bit(const unsigned long *addr,
71 unsigned long size);
72#else /* CONFIG_GENERIC_FIND_FIRST_BIT */
73
Clement Courbet0ade34c2018-02-06 15:38:34 -080074#ifndef find_first_bit
Akinobu Mitac7f612c2006-03-26 01:39:11 -080075#define find_first_bit(addr, size) find_next_bit((addr), (size), 0)
Clement Courbet0ade34c2018-02-06 15:38:34 -080076#endif
77#ifndef find_first_zero_bit
Akinobu Mitac7f612c2006-03-26 01:39:11 -080078#define find_first_zero_bit(addr, size) find_next_zero_bit((addr), (size), 0)
Clement Courbet0ade34c2018-02-06 15:38:34 -080079#endif
Akinobu Mitac7f612c2006-03-26 01:39:11 -080080
Akinobu Mita708ff2a2010-09-29 18:08:50 +090081#endif /* CONFIG_GENERIC_FIND_FIRST_BIT */
82
Akinobu Mitac7f612c2006-03-26 01:39:11 -080083#endif /*_ASM_GENERIC_BITOPS_FIND_H_ */