]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
linux/bitmap.h: add bitmap_empty helper
authorCaleb Connolly <caleb.connolly@linaro.org>
Mon, 15 Jul 2024 10:08:01 +0000 (12:08 +0200)
committerCaleb Connolly <caleb.connolly@linaro.org>
Thu, 25 Jul 2024 23:28:09 +0000 (01:28 +0200)
Import this function from Linux as of 6.10-rc6

Reviewed-by: Tom Rini <trini@konsulko.com>
Acked-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
include/linux/bitmap.h

index 0a8503af9f1461944a6be0e3180aa2a039b5d509..40ca2212cb4075b69a019ebce71c9e9fed737b2a 100644 (file)
@@ -196,6 +196,14 @@ static inline void bitmap_fill(unsigned long *dst, unsigned int nbits)
        }
 }
 
+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)
 {