aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bitmap.c
diff options
context:
space:
mode:
authorYury Norov <[email protected]>2024-01-29 06:21:04 +0000
committerPaolo Abeni <[email protected]>2024-02-01 12:06:40 +0000
commitc1f5204efcbcced83f67f12fa8f1a7f5f244fb87 (patch)
tree4cf65b8c65041554ba6cdccd75ace4b62f247028 /lib/bitmap.c
parentnet: dsa: Add KSZ8567 switch support (diff)
downloadkernel-c1f5204efcbcced83f67f12fa8f1a7f5f244fb87.tar.gz
kernel-c1f5204efcbcced83f67f12fa8f1a7f5f244fb87.zip
cpumask: add cpumask_weight_andnot()
Similarly to cpumask_weight_and(), cpumask_weight_andnot() is a handy helper that may help to avoid creating an intermediate mask just to calculate number of bits that set in a 1st given mask, and clear in 2nd one. Signed-off-by: Yury Norov <[email protected]> Reviewed-by: Jacob Keller <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
Diffstat (limited to 'lib/bitmap.c')
-rw-r--r--lib/bitmap.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/bitmap.c b/lib/bitmap.c
index 09522af227f1..b97692854966 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -348,6 +348,13 @@ unsigned int __bitmap_weight_and(const unsigned long *bitmap1,
}
EXPORT_SYMBOL(__bitmap_weight_and);
+unsigned int __bitmap_weight_andnot(const unsigned long *bitmap1,
+ const unsigned long *bitmap2, unsigned int bits)
+{
+ return BITMAP_WEIGHT(bitmap1[idx] & ~bitmap2[idx], bits);
+}
+EXPORT_SYMBOL(__bitmap_weight_andnot);
+
void __bitmap_set(unsigned long *map, unsigned int start, int len)
{
unsigned long *p = map + BIT_WORD(start);