Linux 6.13-rc1
[linux-2.6-microblaze.git] / lib / find_bit.c
index c10920e..0836bb3 100644 (file)
@@ -87,7 +87,7 @@ out:                                                                          \
        if (sz % BITS_PER_LONG)                                                 \
                tmp = (FETCH) & BITMAP_LAST_WORD_MASK(sz);                      \
 found:                                                                         \
-       sz = min(idx * BITS_PER_LONG + fns(tmp, nr), sz);                       \
+       sz = idx * BITS_PER_LONG + fns(tmp, nr);                                \
 out:                                                                           \
        sz;                                                                     \
 })
@@ -116,6 +116,18 @@ unsigned long _find_first_and_bit(const unsigned long *addr1,
 EXPORT_SYMBOL(_find_first_and_bit);
 #endif
 
+/*
+ * Find the first set bit in three memory regions.
+ */
+unsigned long _find_first_and_and_bit(const unsigned long *addr1,
+                                     const unsigned long *addr2,
+                                     const unsigned long *addr3,
+                                     unsigned long size)
+{
+       return FIND_FIRST_BIT(addr1[idx] & addr2[idx] & addr3[idx], /* nop */, size);
+}
+EXPORT_SYMBOL(_find_first_and_and_bit);
+
 #ifndef find_first_zero_bit
 /*
  * Find the first cleared bit in a memory region.
@@ -182,6 +194,15 @@ unsigned long _find_next_andnot_bit(const unsigned long *addr1, const unsigned l
 EXPORT_SYMBOL(_find_next_andnot_bit);
 #endif
 
+#ifndef find_next_or_bit
+unsigned long _find_next_or_bit(const unsigned long *addr1, const unsigned long *addr2,
+                                       unsigned long nbits, unsigned long start)
+{
+       return FIND_NEXT_BIT(addr1[idx] | addr2[idx], /* nop */, nbits, start);
+}
+EXPORT_SYMBOL(_find_next_or_bit);
+#endif
+
 #ifndef find_next_zero_bit
 unsigned long _find_next_zero_bit(const unsigned long *addr, unsigned long nbits,
                                         unsigned long start)