From: Chunguang Xu <brookxu@xxxxxxxxxxx> Use do_div() to calculate the block offset and the offset within the block, make the code more concise. Signed-off-by: Chunguang Xu <brookxu@xxxxxxxxxxx> --- fs/ext4/balloc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c index db7fa3e..4013676 100644 --- a/fs/ext4/balloc.c +++ b/fs/ext4/balloc.c @@ -265,7 +265,7 @@ struct ext4_group_desc * ext4_get_group_desc(struct super_block *sb, ext4_group_t block_group, struct buffer_head **bh) { - unsigned int group_desc; + unsigned int group_desc = block_group; unsigned int offset; ext4_group_t ngroups = ext4_get_groups_count(sb); struct ext4_group_desc *desc; @@ -279,8 +279,7 @@ struct ext4_group_desc * ext4_get_group_desc(struct super_block *sb, return NULL; } - group_desc = block_group >> EXT4_DESC_PER_BLOCK_BITS(sb); - offset = block_group & (EXT4_DESC_PER_BLOCK(sb) - 1); + offset = do_div(group_desc, EXT4_DESC_PER_BLOCK(sb)); bh_p = sbi_array_rcu_deref(sbi, s_group_desc, group_desc); /* * sbi_array_rcu_deref returns with rcu unlocked, this is ok since -- 1.8.3.1