diff mbox series

[v4,01/21] linux/bitmap.h: add bitmap_empty helper

Message ID 20240709-b4-qcom-rpmh-v4-1-c06d0a26644a@linaro.org
State Superseded
Headers show
Series qcom: rpmh core and regulator support | expand

Commit Message

Caleb Connolly July 9, 2024, 9:34 a.m. UTC
Import this function from Linux as of 6.10-rc6

Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
---
 include/linux/bitmap.h | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Tom Rini July 9, 2024, 5:09 p.m. UTC | #1
On Tue, Jul 09, 2024 at 11:34:29AM +0200, Caleb Connolly wrote:

> Import this function from Linux as of 6.10-rc6
> 
> Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>

Reviewed-by: Tom Rini <trini@konsulko.com>
diff mbox series

Patch

diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index 0a8503af9f14..40ca2212cb40 100644
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -195,8 +195,16 @@  static inline void bitmap_fill(unsigned long *dst, unsigned int nbits)
 		memset(dst, 0xff, len);
 	}
 }
 
+static inline bool bitmap_empty(const unsigned long *src, unsigned int nbits)
+{
+	if (small_const_nbits(nbits))
+		return !(*src & BITMAP_LAST_WORD_MASK(nbits));
+
+	return find_first_bit(src, nbits) == nbits;
+}
+
 static inline void bitmap_or(unsigned long *dst, const unsigned long *src1,
 			     const unsigned long *src2, unsigned int nbits)
 {
 	if (small_const_nbits(nbits))