Merge tag 'regulator-fix-v5.17-rc4' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6-microblaze.git] / lib / find_bit.c
index 0f8e2e3..1b8e4b2 100644 (file)
@@ -89,6 +89,27 @@ unsigned long _find_first_bit(const unsigned long *addr, unsigned long size)
 EXPORT_SYMBOL(_find_first_bit);
 #endif
 
+#ifndef find_first_and_bit
+/*
+ * Find the first set bit in two memory regions.
+ */
+unsigned long _find_first_and_bit(const unsigned long *addr1,
+                                 const unsigned long *addr2,
+                                 unsigned long size)
+{
+       unsigned long idx, val;
+
+       for (idx = 0; idx * BITS_PER_LONG < size; idx++) {
+               val = addr1[idx] & addr2[idx];
+               if (val)
+                       return min(idx * BITS_PER_LONG + __ffs(val), size);
+       }
+
+       return size;
+}
+EXPORT_SYMBOL(_find_first_and_bit);
+#endif
+
 #ifndef find_first_zero_bit
 /*
  * Find the first cleared bit in a memory region.