summaryrefslogtreecommitdiff
path: root/fs/qnx4/bitmap.c
diff options
context:
space:
mode:
authorAkinobu Mita <akinobu.mita@gmail.com>2012-07-30 14:40:57 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2012-07-30 17:25:16 -0700
commit9b58f6d4aaef070bf6e0744713b6d2b6fc1b3578 (patch)
tree67b220d36ae96abb0a4551d0ead65e3c0c599704 /fs/qnx4/bitmap.c
parent639b9e34f15e4b2c30068a4e4485586af0cdf709 (diff)
qnx4fs: use memweight()
Use memweight() to count the total number of bits clear in memory area. Note that this memweight() call can't be replaced with a single bitmap_weight() call, although the pointer to the memory area is aligned to long-word boundary. Because the size of the memory area may not be a multiple of BITS_PER_LONG, then it returns wrong value on big-endian architecture. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Acked-by: Anders Larsen <al@alarsen.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/qnx4/bitmap.c')
-rw-r--r--fs/qnx4/bitmap.c24
1 files changed, 5 insertions, 19 deletions
diff --git a/fs/qnx4/bitmap.c b/fs/qnx4/bitmap.c
index 22e0d60e53ef..76a7a697b778 100644
--- a/fs/qnx4/bitmap.c
+++ b/fs/qnx4/bitmap.c
@@ -17,23 +17,6 @@
#include <linux/bitops.h>
#include "qnx4.h"
-static void count_bits(register const char *bmPart, register int size,
- int *const tf)
-{
- char b;
- int tot = *tf;
-
- if (size > QNX4_BLOCK_SIZE) {
- size = QNX4_BLOCK_SIZE;
- }
- do {
- b = *bmPart++;
- tot += 8 - hweight8(b);
- size--;
- } while (size != 0);
- *tf = tot;
-}
-
unsigned long qnx4_count_free_blocks(struct super_block *sb)
{
int start = le32_to_cpu(qnx4_sb(sb)->BitMap->di_first_xtnt.xtnt_blk) - 1;
@@ -44,13 +27,16 @@ unsigned long qnx4_count_free_blocks(struct super_block *sb)
struct buffer_head *bh;
while (total < size) {
+ int bytes = min(size - total, QNX4_BLOCK_SIZE);
+
if ((bh = sb_bread(sb, start + offset)) == NULL) {
printk(KERN_ERR "qnx4: I/O error in counting free blocks\n");
break;
}
- count_bits(bh->b_data, size - total, &total_free);
+ total_free += bytes * BITS_PER_BYTE -
+ memweight(bh->b_data, bytes);
brelse(bh);
- total += QNX4_BLOCK_SIZE;
+ total += bytes;
offset++;
}