Skip to contentSkip to conversation

bitops/find.h: Add declaration find_last_zero_bit

PATCH In review Levi Yun 1 participant 1 message Dec 6, 2020

Subsystems (3)
lore
Share & tools
lore

Levi Yun

author
#0 lore raw

PATCH v2 3/8 bitops/find.h: Add declaration find_last_zero_bit

Inspired find_next_*_bit function series, add find_last_zero_bit. These patch adds declarations for find_last_zero_bit.
Also, I move declaration of find_last_bit to asm-generic/bitops/find.h Because:
I think its declaration need not to in __KERNEL__ macro compared to find_next_*_bit and find_first_*_bit.

---
 include/asm-generic/bitops/find.h | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
include/asm-generic/bitops/find.h +25 -0
index 9fdf21302fdf..eeb2d6669f83 100644
@@ -80,6 +80,31 @@ extern unsigned long find_first_zero_bit(const unsigned long *addr,
 
 #endif /* CONFIG_GENERIC_FIND_FIRST_BIT */
 
+#ifndef find_last_bit
+/**
+ * find_last_bit - find the last set bit in a memory region
+ * @addr: The address to start the search at
+ * @size: The number of bits to search
+ *
+ * Returns the bit number of the last set bit, or size.
+ */
+extern unsigned long find_last_bit(const unsigned long *addr,
+				   unsigned long size);
+#endif
+
+#ifndef find_last_zero_bit
+/**
+ * find_last_zero_bit - find the last cleared bit in a memory region
+ * @addr: The address to start the search at
+ * @size: The maximum number of bits to search
+ *
+ * Returns the bit number of the first cleared bit.
+ * If no bits are zero, returns @size.
+ */
+extern unsigned long find_last_zero_bit(const unsigned long *addr,
+					 unsigned long size);
+#endif
+
 /**
  * find_next_clump8 - find next 8-bit clump with set bits in a memory region
  * @clump: location to store copy of found clump
Signature · 1 line
2.27.0