Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

lib/find_bit: create find_first_zero_bit_le()

find_first_zero_bit_le() is an alias to find_next_zero_bit_le(),
despite that 'next' is known to be slower than 'first' version.

Now that we have common FIND_FIRST_BIT() macro helper, it's trivial
to implement find_first_zero_bit_le() as a real function.

Reviewed-by: Valentin Schneider <vschneid@redhat.com>
Signed-off-by: Yury Norov <yury.norov@gmail.com>

+34 -5
+18 -5
include/linux/find.h
··· 17 17 extern unsigned long _find_first_zero_bit(const unsigned long *addr, unsigned long size); 18 18 extern unsigned long _find_last_bit(const unsigned long *addr, unsigned long size); 19 19 20 + #ifdef __BIG_ENDIAN 21 + unsigned long _find_first_zero_bit_le(const unsigned long *addr, unsigned long size); 22 + #endif 23 + 20 24 #ifndef find_next_bit 21 25 /** 22 26 * find_next_bit - find the next set bit in a memory region ··· 255 251 } 256 252 #endif 257 253 254 + #ifndef find_first_zero_bit_le 255 + static inline 256 + unsigned long find_first_zero_bit_le(const void *addr, unsigned long size) 257 + { 258 + if (small_const_nbits(size)) { 259 + unsigned long val = swab(*(const unsigned long *)addr) | ~GENMASK(size - 1, 0); 260 + 261 + return val == ~0UL ? size : ffz(val); 262 + } 263 + 264 + return _find_first_zero_bit_le(addr, size); 265 + } 266 + #endif 267 + 258 268 #ifndef find_next_bit_le 259 269 static inline 260 270 unsigned long find_next_bit_le(const void *addr, unsigned ··· 286 268 287 269 return _find_next_bit(addr, NULL, size, offset, 0UL, 1); 288 270 } 289 - #endif 290 - 291 - #ifndef find_first_zero_bit_le 292 - #define find_first_zero_bit_le(addr, size) \ 293 - find_next_zero_bit_le((addr), (size), 0) 294 271 #endif 295 272 296 273 #else
+16
lib/find_bit.c
··· 160 160 return offset; 161 161 } 162 162 EXPORT_SYMBOL(find_next_clump8); 163 + 164 + #ifdef __BIG_ENDIAN 165 + 166 + #ifndef find_first_zero_bit_le 167 + /* 168 + * Find the first cleared bit in an LE memory region. 169 + */ 170 + unsigned long _find_first_zero_bit_le(const unsigned long *addr, unsigned long size) 171 + { 172 + return FIND_FIRST_BIT(~addr[idx], swab, size); 173 + } 174 + EXPORT_SYMBOL(_find_first_zero_bit_le); 175 + 176 + #endif 177 + 178 + #endif /* __BIG_ENDIAN */