diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2012-07-30 17:40:59 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-07-30 20:25:16 -0400 |
commit | 8fb980e35b41bbb79aa47f48839d95f0354af3c4 (patch) | |
tree | dbc1395e9a1cc27911e597ed83bad9c126335891 /drivers/md/dm-log.c | |
parent | 9b58f6d4aaef070bf6e0744713b6d2b6fc1b3578 (diff) |
dm: use memweight()
Use memweight() to count the total number of bits set in memory area.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Alasdair Kergon <agk@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/md/dm-log.c')
-rw-r--r-- | drivers/md/dm-log.c | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/drivers/md/dm-log.c b/drivers/md/dm-log.c index 65ebaebf502b..627d19186d5a 100644 --- a/drivers/md/dm-log.c +++ b/drivers/md/dm-log.c | |||
@@ -571,16 +571,6 @@ static void disk_dtr(struct dm_dirty_log *log) | |||
571 | destroy_log_context(lc); | 571 | destroy_log_context(lc); |
572 | } | 572 | } |
573 | 573 | ||
574 | static int count_bits32(uint32_t *addr, unsigned size) | ||
575 | { | ||
576 | int count = 0, i; | ||
577 | |||
578 | for (i = 0; i < size; i++) { | ||
579 | count += hweight32(*(addr+i)); | ||
580 | } | ||
581 | return count; | ||
582 | } | ||
583 | |||
584 | static void fail_log_device(struct log_c *lc) | 574 | static void fail_log_device(struct log_c *lc) |
585 | { | 575 | { |
586 | if (lc->log_dev_failed) | 576 | if (lc->log_dev_failed) |
@@ -629,7 +619,8 @@ static int disk_resume(struct dm_dirty_log *log) | |||
629 | 619 | ||
630 | /* copy clean across to sync */ | 620 | /* copy clean across to sync */ |
631 | memcpy(lc->sync_bits, lc->clean_bits, size); | 621 | memcpy(lc->sync_bits, lc->clean_bits, size); |
632 | lc->sync_count = count_bits32(lc->clean_bits, lc->bitset_uint32_count); | 622 | lc->sync_count = memweight(lc->clean_bits, |
623 | lc->bitset_uint32_count * sizeof(uint32_t)); | ||
633 | lc->sync_search = 0; | 624 | lc->sync_search = 0; |
634 | 625 | ||
635 | /* set the correct number of regions in the header */ | 626 | /* set the correct number of regions in the header */ |