Skip to content

Commit

Permalink
bitmap: use for_each_set_bit()
Browse files Browse the repository at this point in the history
Replace open-coded loop with for_each_set_bit().

Signed-off-by: Akinobu Mita <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
mita authored and torvalds committed Mar 6, 2010
1 parent 9a86e2b commit 08564fb
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions lib/bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -733,10 +733,9 @@ void bitmap_remap(unsigned long *dst, const unsigned long *src,
bitmap_zero(dst, bits);

w = bitmap_weight(new, bits);
for (oldbit = find_first_bit(src, bits);
oldbit < bits;
oldbit = find_next_bit(src, bits, oldbit + 1)) {
for_each_set_bit(oldbit, src, bits) {
int n = bitmap_pos_to_ord(old, oldbit, bits);

if (n < 0 || w == 0)
set_bit(oldbit, dst); /* identity map */
else
Expand Down Expand Up @@ -903,9 +902,7 @@ void bitmap_onto(unsigned long *dst, const unsigned long *orig,
*/

m = 0;
for (n = find_first_bit(relmap, bits);
n < bits;
n = find_next_bit(relmap, bits, n + 1)) {
for_each_set_bit(n, relmap, bits) {
/* m == bitmap_pos_to_ord(relmap, n, bits) */
if (test_bit(m, orig))
set_bit(n, dst);
Expand Down Expand Up @@ -934,9 +931,7 @@ void bitmap_fold(unsigned long *dst, const unsigned long *orig,
return;
bitmap_zero(dst, bits);

for (oldbit = find_first_bit(orig, bits);
oldbit < bits;
oldbit = find_next_bit(orig, bits, oldbit + 1))
for_each_set_bit(oldbit, orig, bits)
set_bit(oldbit % sz, dst);
}
EXPORT_SYMBOL(bitmap_fold);
Expand Down

0 comments on commit 08564fb

Please sign in to comment.