From: Charles Manning Date: Sun, 5 Dec 2010 21:45:02 +0000 (+1300) Subject: yaffs : Change bitmap counting function to use hweight8() X-Git-Tag: linux-mainline-patchset-4~11^2 X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=commitdiff_plain;h=7620f7d1207e72dc6b3c58bc452000b9ec82b57b yaffs : Change bitmap counting function to use hweight8() Better than shift counting. Signed-off-by: Charles Manning --- diff --git a/yaffs_bitmap.c b/yaffs_bitmap.c index 5d1cfb2..b254266 100644 --- a/yaffs_bitmap.c +++ b/yaffs_bitmap.c @@ -90,15 +90,9 @@ int yaffs_count_chunk_bits(struct yaffs_dev *dev, int blk) u8 *blk_bits = yaffs_block_bits(dev, blk); int i; int n = 0; - for (i = 0; i < dev->chunk_bit_stride; i++) { - u8 x = *blk_bits; - while (x) { - if (x & 1) - n++; - x >>= 1; - } - blk_bits++; - } + for (i = 0; i < dev->chunk_bit_stride; i++, blk_bits++) + n += hweight8(*blk_bits); + return n; }