@@ -29,6 +29,8 @@ unsigned long __find_nth_and_andnot_bit(const unsigned long *addr1, const unsign
29
29
unsigned long n );
30
30
extern unsigned long _find_first_and_bit (const unsigned long * addr1 ,
31
31
const unsigned long * addr2 , unsigned long size );
32
+ unsigned long _find_first_andnot_bit (const unsigned long * addr1 , const unsigned long * addr2 ,
33
+ unsigned long size );
32
34
unsigned long _find_first_and_and_bit (const unsigned long * addr1 , const unsigned long * addr2 ,
33
35
const unsigned long * addr3 , unsigned long size );
34
36
extern unsigned long _find_first_zero_bit (const unsigned long * addr , unsigned long size );
@@ -347,6 +349,29 @@ unsigned long find_first_and_bit(const unsigned long *addr1,
347
349
}
348
350
#endif
349
351
352
+ /**
353
+ * find_first_andnot_bit - find the first bit set in 1st memory region and unset in 2nd
354
+ * @addr1: The first address to base the search on
355
+ * @addr2: The second address to base the search on
356
+ * @size: The bitmap size in bits
357
+ *
358
+ * Returns the bit number for the first set bit
359
+ * If no bits are set, returns >= @size.
360
+ */
361
+ static __always_inline
362
+ unsigned long find_first_andnot_bit (const unsigned long * addr1 ,
363
+ const unsigned long * addr2 ,
364
+ unsigned long size )
365
+ {
366
+ if (small_const_nbits (size )) {
367
+ unsigned long val = * addr1 & (~* addr2 ) & GENMASK (size - 1 , 0 );
368
+
369
+ return val ? __ffs (val ) : size ;
370
+ }
371
+
372
+ return _find_first_andnot_bit (addr1 , addr2 , size );
373
+ }
374
+
350
375
/**
351
376
* find_first_and_and_bit - find the first set bit in 3 memory regions
352
377
* @addr1: The first address to base the search on
0 commit comments