Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755535Ab2ETNZH (ORCPT ); Sun, 20 May 2012 09:25:07 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:50441 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755000Ab2ETNYB (ORCPT ); Sun, 20 May 2012 09:24:01 -0400 From: Akinobu Mita To: linux-kernel@vger.kernel.org, akpm@linux-foundation.org Cc: Akinobu Mita , Alasdair Kergon , dm-devel@redhat.com Subject: [PATCH 04/10] dm-log: use memweight() Date: Sun, 20 May 2012 22:23:17 +0900 Message-Id: <1337520203-29147-4-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1337520203-29147-1-git-send-email-akinobu.mita@gmail.com> References: <1337520203-29147-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1427 Lines: 48 Use memweight() to count the total number of bits set in memory area. Signed-off-by: Akinobu Mita Cc: Alasdair Kergon Cc: dm-devel@redhat.com --- 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 65ebaeb..627d191 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) destroy_log_context(lc); } -static int count_bits32(uint32_t *addr, unsigned size) -{ - int count = 0, i; - - for (i = 0; i < size; i++) { - count += hweight32(*(addr+i)); - } - return count; -} - static void fail_log_device(struct log_c *lc) { if (lc->log_dev_failed) @@ -629,7 +619,8 @@ static int disk_resume(struct dm_dirty_log *log) /* copy clean across to sync */ memcpy(lc->sync_bits, lc->clean_bits, size); - lc->sync_count = count_bits32(lc->clean_bits, lc->bitset_uint32_count); + lc->sync_count = memweight(lc->clean_bits, + lc->bitset_uint32_count * sizeof(uint32_t)); lc->sync_search = 0; /* set the correct number of regions in the header */ -- 1.7.7.6 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/