[PATCH] sbitmap: simplify __sbitmap_for_each_set()

Yury Norov posted 1 patch 2 months, 2 weeks ago
include/linux/sbitmap.h | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
[PATCH] sbitmap: simplify __sbitmap_for_each_set()
Posted by Yury Norov 2 months, 2 weeks ago
From: Yury Norov (NVIDIA) <yury.norov@gmail.com>

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@gmail.com>
---
 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