@@ -114,8 +114,6 @@ static inline unsigned fls_long(unsigned long l)
114114
115115#ifdef __KERNEL__
116116#ifdef CONFIG_GENERIC_FIND_FIRST_BIT
117- extern unsigned long __find_first_bit (const unsigned long * addr ,
118- unsigned long size );
119117
120118/**
121119 * find_first_bit - find the first set bit in a memory region
@@ -124,28 +122,8 @@ extern unsigned long __find_first_bit(const unsigned long *addr,
124122 *
125123 * Returns the bit number of the first set bit.
126124 */
127- static __always_inline unsigned long
128- find_first_bit (const unsigned long * addr , unsigned long size )
129- {
130- /* Avoid a function call if the bitmap size is a constant */
131- /* and not bigger than BITS_PER_LONG. */
132-
133- /* insert a sentinel so that __ffs returns size if there */
134- /* are no set bits in the bitmap */
135- if (__builtin_constant_p (size ) && (size < BITS_PER_LONG ))
136- return __ffs ((* addr ) | (1ul << size ));
137-
138- /* the result of __ffs(0) is undefined, so it needs to be */
139- /* handled separately */
140- if (__builtin_constant_p (size ) && (size == BITS_PER_LONG ))
141- return ((* addr ) == 0 ) ? BITS_PER_LONG : __ffs (* addr );
142-
143- /* size is not constant or too big */
144- return __find_first_bit (addr , size );
145- }
146-
147- extern unsigned long __find_first_zero_bit (const unsigned long * addr ,
148- unsigned long size );
125+ extern unsigned long find_first_bit (const unsigned long * addr ,
126+ unsigned long size );
149127
150128/**
151129 * find_first_zero_bit - find the first cleared bit in a memory region
@@ -154,102 +132,33 @@ extern unsigned long __find_first_zero_bit(const unsigned long *addr,
154132 *
155133 * Returns the bit number of the first cleared bit.
156134 */
157- static __always_inline unsigned long
158- find_first_zero_bit (const unsigned long * addr , unsigned long size )
159- {
160- /* Avoid a function call if the bitmap size is a constant */
161- /* and not bigger than BITS_PER_LONG. */
162-
163- /* insert a sentinel so that __ffs returns size if there */
164- /* are no set bits in the bitmap */
165- if (__builtin_constant_p (size ) && (size < BITS_PER_LONG )) {
166- return __ffs (~(* addr ) | (1ul << size ));
167- }
168-
169- /* the result of __ffs(0) is undefined, so it needs to be */
170- /* handled separately */
171- if (__builtin_constant_p (size ) && (size == BITS_PER_LONG ))
172- return (~(* addr ) == 0 ) ? BITS_PER_LONG : __ffs (~(* addr ));
173-
174- /* size is not constant or too big */
175- return __find_first_zero_bit (addr , size );
176- }
135+ extern unsigned long find_first_zero_bit (const unsigned long * addr ,
136+ unsigned long size );
137+
177138#endif /* CONFIG_GENERIC_FIND_FIRST_BIT */
178139
179140#ifdef CONFIG_GENERIC_FIND_NEXT_BIT
180- extern unsigned long __find_next_bit (const unsigned long * addr ,
181- unsigned long size , unsigned long offset );
182141
183142/**
184143 * find_next_bit - find the next set bit in a memory region
185144 * @addr: The address to base the search on
186145 * @offset: The bitnumber to start searching at
187146 * @size: The bitmap size in bits
188147 */
189- static __always_inline unsigned long
190- find_next_bit (const unsigned long * addr , unsigned long size ,
191- unsigned long offset )
192- {
193- unsigned long value ;
194-
195- /* Avoid a function call if the bitmap size is a constant */
196- /* and not bigger than BITS_PER_LONG. */
197-
198- /* insert a sentinel so that __ffs returns size if there */
199- /* are no set bits in the bitmap */
200- if (__builtin_constant_p (size ) && (size < BITS_PER_LONG )) {
201- value = (* addr ) & ((~0ul ) << offset );
202- value |= (1ul << size );
203- return __ffs (value );
204- }
205-
206- /* the result of __ffs(0) is undefined, so it needs to be */
207- /* handled separately */
208- if (__builtin_constant_p (size ) && (size == BITS_PER_LONG )) {
209- value = (* addr ) & ((~0ul ) << offset );
210- return (value == 0 ) ? BITS_PER_LONG : __ffs (value );
211- }
212-
213- /* size is not constant or too big */
214- return __find_next_bit (addr , size , offset );
215- }
216-
217- extern unsigned long __find_next_zero_bit (const unsigned long * addr ,
218- unsigned long size , unsigned long offset );
148+ extern unsigned long find_next_bit (const unsigned long * addr ,
149+ unsigned long size , unsigned long offset );
219150
220151/**
221152 * find_next_zero_bit - find the next cleared bit in a memory region
222153 * @addr: The address to base the search on
223154 * @offset: The bitnumber to start searching at
224155 * @size: The bitmap size in bits
225156 */
226- static __always_inline unsigned long
227- find_next_zero_bit (const unsigned long * addr , unsigned long size ,
228- unsigned long offset )
229- {
230- unsigned long value ;
231-
232- /* Avoid a function call if the bitmap size is a constant */
233- /* and not bigger than BITS_PER_LONG. */
234-
235- /* insert a sentinel so that __ffs returns size if there */
236- /* are no set bits in the bitmap */
237- if (__builtin_constant_p (size ) && (size < BITS_PER_LONG )) {
238- value = (~(* addr )) & ((~0ul ) << offset );
239- value |= (1ul << size );
240- return __ffs (value );
241- }
242-
243- /* the result of __ffs(0) is undefined, so it needs to be */
244- /* handled separately */
245- if (__builtin_constant_p (size ) && (size == BITS_PER_LONG )) {
246- value = (~(* addr )) & ((~0ul ) << offset );
247- return (value == 0 ) ? BITS_PER_LONG : __ffs (value );
248- }
249-
250- /* size is not constant or too big */
251- return __find_next_zero_bit (addr , size , offset );
252- }
157+
158+ extern unsigned long find_next_zero_bit (const unsigned long * addr ,
159+ unsigned long size ,
160+ unsigned long offset );
161+
253162#endif /* CONFIG_GENERIC_FIND_NEXT_BIT */
254163#endif /* __KERNEL__ */
255164#endif
0 commit comments