diff options
| author | Akinobu Mita <akinobu.mita@gmail.com> | 2012-07-30 17:41:00 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-07-30 20:25:16 -0400 |
| commit | 0121ad62c20ed779e38ad689071da2805f03249f (patch) | |
| tree | f57cfaedca6a8301cd955a6160dcf256025c9541 /fs/affs | |
| parent | 8fb980e35b41bbb79aa47f48839d95f0354af3c4 (diff) | |
affs: use memweight()
Use memweight() to count the total number of bits set in memory area.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/affs')
| -rw-r--r-- | fs/affs/bitmap.c | 28 |
1 files changed, 2 insertions, 26 deletions
diff --git a/fs/affs/bitmap.c b/fs/affs/bitmap.c index 6e0be43ef6e..a32246b8359 100644 --- a/fs/affs/bitmap.c +++ b/fs/affs/bitmap.c | |||
| @@ -10,30 +10,6 @@ | |||
| 10 | #include <linux/slab.h> | 10 | #include <linux/slab.h> |
| 11 | #include "affs.h" | 11 | #include "affs.h" |
| 12 | 12 | ||
| 13 | /* This is, of course, shamelessly stolen from fs/minix */ | ||
| 14 | |||
| 15 | static const int nibblemap[] = { 0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4 }; | ||
| 16 | |||
| 17 | static u32 | ||
| 18 | affs_count_free_bits(u32 blocksize, const void *data) | ||
| 19 | { | ||
| 20 | const u32 *map; | ||
| 21 | u32 free; | ||
| 22 | u32 tmp; | ||
| 23 | |||
| 24 | map = data; | ||
| 25 | free = 0; | ||
| 26 | for (blocksize /= 4; blocksize > 0; blocksize--) { | ||
| 27 | tmp = *map++; | ||
| 28 | while (tmp) { | ||
| 29 | free += nibblemap[tmp & 0xf]; | ||
| 30 | tmp >>= 4; | ||
| 31 | } | ||
| 32 | } | ||
| 33 | |||
| 34 | return free; | ||
| 35 | } | ||
| 36 | |||
| 37 | u32 | 13 | u32 |
| 38 | affs_count_free_blocks(struct super_block *sb) | 14 | affs_count_free_blocks(struct super_block *sb) |
| 39 | { | 15 | { |
| @@ -317,7 +293,7 @@ int affs_init_bitmap(struct super_block *sb, int *flags) | |||
| 317 | goto out; | 293 | goto out; |
| 318 | } | 294 | } |
| 319 | pr_debug("AFFS: read bitmap block %d: %d\n", blk, bm->bm_key); | 295 | pr_debug("AFFS: read bitmap block %d: %d\n", blk, bm->bm_key); |
| 320 | bm->bm_free = affs_count_free_bits(sb->s_blocksize - 4, bh->b_data + 4); | 296 | bm->bm_free = memweight(bh->b_data + 4, sb->s_blocksize - 4); |
| 321 | 297 | ||
| 322 | /* Don't try read the extension if this is the last block, | 298 | /* Don't try read the extension if this is the last block, |
| 323 | * but we also need the right bm pointer below | 299 | * but we also need the right bm pointer below |
| @@ -367,7 +343,7 @@ int affs_init_bitmap(struct super_block *sb, int *flags) | |||
| 367 | 343 | ||
| 368 | /* recalculate bitmap count for last block */ | 344 | /* recalculate bitmap count for last block */ |
| 369 | bm--; | 345 | bm--; |
| 370 | bm->bm_free = affs_count_free_bits(sb->s_blocksize - 4, bh->b_data + 4); | 346 | bm->bm_free = memweight(bh->b_data + 4, sb->s_blocksize - 4); |
| 371 | 347 | ||
| 372 | out: | 348 | out: |
| 373 | affs_brelse(bh); | 349 | affs_brelse(bh); |
