Commit 01b954a3 authored by Marcin Slusarz's avatar Marcin Slusarz Committed by Jan Kara

udf: convert udf_count_free_bitmap to use bitmap_weight

replace handwritten bits counting with bitmap_weight
Signed-off-by: default avatarMarcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
parent d652eefb
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/mount.h> #include <linux/mount.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/bitmap.h>
#include <asm/byteorder.h> #include <asm/byteorder.h>
#include "udf_sb.h" #include "udf_sb.h"
...@@ -1958,10 +1959,6 @@ static int udf_statfs(struct dentry *dentry, struct kstatfs *buf) ...@@ -1958,10 +1959,6 @@ static int udf_statfs(struct dentry *dentry, struct kstatfs *buf)
return 0; return 0;
} }
static unsigned char udf_bitmap_lookup[16] = {
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4
};
static unsigned int udf_count_free_bitmap(struct super_block *sb, static unsigned int udf_count_free_bitmap(struct super_block *sb,
struct udf_bitmap *bitmap) struct udf_bitmap *bitmap)
{ {
...@@ -1971,7 +1968,6 @@ static unsigned int udf_count_free_bitmap(struct super_block *sb, ...@@ -1971,7 +1968,6 @@ static unsigned int udf_count_free_bitmap(struct super_block *sb,
int block = 0, newblock; int block = 0, newblock;
kernel_lb_addr loc; kernel_lb_addr loc;
uint32_t bytes; uint32_t bytes;
uint8_t value;
uint8_t *ptr; uint8_t *ptr;
uint16_t ident; uint16_t ident;
struct spaceBitmapDesc *bm; struct spaceBitmapDesc *bm;
...@@ -1997,13 +1993,10 @@ static unsigned int udf_count_free_bitmap(struct super_block *sb, ...@@ -1997,13 +1993,10 @@ static unsigned int udf_count_free_bitmap(struct super_block *sb,
ptr = (uint8_t *)bh->b_data; ptr = (uint8_t *)bh->b_data;
while (bytes > 0) { while (bytes > 0) {
while ((bytes > 0) && (index < sb->s_blocksize)) { u32 cur_bytes = min_t(u32, bytes, sb->s_blocksize - index);
value = ptr[index]; accum += bitmap_weight((const unsigned long *)(ptr + index),
accum += udf_bitmap_lookup[value & 0x0f]; cur_bytes * 8);
accum += udf_bitmap_lookup[value >> 4]; bytes -= cur_bytes;
index++;
bytes--;
}
if (bytes) { if (bytes) {
brelse(bh); brelse(bh);
newblock = udf_get_lb_pblock(sb, loc, ++block); newblock = udf_get_lb_pblock(sb, loc, ++block);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment