[PATCH] sbitmap: simplify __sbitmap_for_each_set()

From: Yury Norov
Date: Sat Jul 19 2025 - 17:24:55 EST


From: Yury Norov (NVIDIA) <yury.norov@xxxxxxxxx>

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

Signed-off-by: Yury Norov (NVIDIA) <yury.norov@xxxxxxxxx>
---
include/linux/sbitmap.h | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/include/linux/sbitmap.h b/include/linux/sbitmap.h
index 189140bf11fc..90a702a249e6 100644
--- a/include/linux/sbitmap.h
+++ b/include/linux/sbitmap.h
@@ -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)
--
2.43.0