diff options
author | Marcin Slusarz <marcin.slusarz@gmail.com> | 2008-02-02 16:37:07 -0500 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2008-04-17 08:22:29 -0400 |
commit | 01b954a36a03d90a66c9dd1fc13e4cb51269caf7 (patch) | |
tree | 5abbd5e79c9858ef20844be77edf3133eda0ed98 | |
parent | d652eefb70142c64495f4188883f9dfc0430a96b (diff) |
udf: convert udf_count_free_bitmap to use bitmap_weight
replace handwritten bits counting with bitmap_weight
Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
-rw-r--r-- | fs/udf/super.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/fs/udf/super.c b/fs/udf/super.c index 2666e5bc69ff..be0aa424b8f1 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c | |||
@@ -55,6 +55,7 @@ | |||
55 | #include <linux/errno.h> | 55 | #include <linux/errno.h> |
56 | #include <linux/mount.h> | 56 | #include <linux/mount.h> |
57 | #include <linux/seq_file.h> | 57 | #include <linux/seq_file.h> |
58 | #include <linux/bitmap.h> | ||
58 | #include <asm/byteorder.h> | 59 | #include <asm/byteorder.h> |
59 | 60 | ||
60 | #include "udf_sb.h" | 61 | #include "udf_sb.h" |
@@ -1958,10 +1959,6 @@ static int udf_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
1958 | return 0; | 1959 | return 0; |
1959 | } | 1960 | } |
1960 | 1961 | ||
1961 | static unsigned char udf_bitmap_lookup[16] = { | ||
1962 | 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 | ||
1963 | }; | ||
1964 | |||
1965 | static unsigned int udf_count_free_bitmap(struct super_block *sb, | 1962 | static unsigned int udf_count_free_bitmap(struct super_block *sb, |
1966 | struct udf_bitmap *bitmap) | 1963 | struct udf_bitmap *bitmap) |
1967 | { | 1964 | { |
@@ -1971,7 +1968,6 @@ static unsigned int udf_count_free_bitmap(struct super_block *sb, | |||
1971 | int block = 0, newblock; | 1968 | int block = 0, newblock; |
1972 | kernel_lb_addr loc; | 1969 | kernel_lb_addr loc; |
1973 | uint32_t bytes; | 1970 | uint32_t bytes; |
1974 | uint8_t value; | ||
1975 | uint8_t *ptr; | 1971 | uint8_t *ptr; |
1976 | uint16_t ident; | 1972 | uint16_t ident; |
1977 | struct spaceBitmapDesc *bm; | 1973 | struct spaceBitmapDesc *bm; |
@@ -1997,13 +1993,10 @@ static unsigned int udf_count_free_bitmap(struct super_block *sb, | |||
1997 | ptr = (uint8_t *)bh->b_data; | 1993 | ptr = (uint8_t *)bh->b_data; |
1998 | 1994 | ||
1999 | while (bytes > 0) { | 1995 | while (bytes > 0) { |
2000 | while ((bytes > 0) && (index < sb->s_blocksize)) { | 1996 | u32 cur_bytes = min_t(u32, bytes, sb->s_blocksize - index); |
2001 | value = ptr[index]; | 1997 | accum += bitmap_weight((const unsigned long *)(ptr + index), |
2002 | accum += udf_bitmap_lookup[value & 0x0f]; | 1998 | cur_bytes * 8); |
2003 | accum += udf_bitmap_lookup[value >> 4]; | 1999 | bytes -= cur_bytes; |
2004 | index++; | ||
2005 | bytes--; | ||
2006 | } | ||
2007 | if (bytes) { | 2000 | if (bytes) { |
2008 | brelse(bh); | 2001 | brelse(bh); |
2009 | newblock = udf_get_lb_pblock(sb, loc, ++block); | 2002 | newblock = udf_get_lb_pblock(sb, loc, ++block); |