Skip to contentSkip to conversation

sbitmap: simplify __sbitmap_for_each_set()

PATCH New Yury Norov 1 participant 1 message Jul 19, 2025

lore
Share & tools
lore

Yury Norov

author
#0 lore raw

PATCH 1/1 sbitmap: simplify __sbitmap_for_each_set()

From: Yury Norov (NVIDIA) <[email protected]>

The function opencodes for_each_set_bit_from(). Fix that and drop most of the housekeeping code.

---
 include/linux/sbitmap.h | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
include/linux/sbitmap.h +1 -7
index 189140bf11fc..90a702a249e6 100644
@@ -279,15 +279,9 @@ static inline void __sbitmap_for_each_set(struct sbitmap *sb,
 		 * On all other iterations, nr is zero, so this is a noop.
 		 */
 		depth += nr;
-		while (1) {
-			nr = find_next_bit(&word, depth, nr);
-			if (nr >= depth)
-				break;
+		for_each_set_bit_from(nr, &word, depth)
 			if (!fn(sb, (index << sb->shift) + nr, data))
 				return;
-
-			nr++;
-		}
 next:
 		nr = 0;
 		if (++index >= sb->map_nr)
Signature · 1 line
2.43.0