fat: Simplify calc_fat_clusters code
Subsystems (2)
PATCH 1/1 fat: Simplify calc_fat_clusters code
Code for fat12 and fat16/32 can be merged to one.
Signed-off-by Seunghun Lee <[email protected]>
--- fs/fat/inode.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
fs/fat/inode.c +2 -5
@@ -1307,12 +1307,9 @@ static unsigned long calc_fat_clusters(struct super_block *sb)struct msdos_sb_info *sbi =MSDOS_SB (sb);/* Divide first to avoid overflow */ -if (sbi->fat_bits !=12 ) { -unsigned long ent_per_sec = sb->s_blocksize *8 / sbi->fat_bits; -return ent_per_sec * sbi->fat_length; - } +unsigned long ent_per_sec = sb->s_blocksize *8 / sbi->fat_bits; -return sbi->fat_length * sb->s_blocksize *8 / sbi->fat_bits; +return ent_per_sec * sbi->fat_length; }static bool fat_bpb_is_zero (struct fat_boot_sector *b)
Signature · 1 line
1.7.9.5
OGAWA Hirofumi
maintainerQuoted 7 lines · Seunghun Lee
fs/fat/inode.c +0
-0@@ -1307,12 +1307,9 @@ static unsigned long calc_fat_clusters(struct super_block *sb)struct msdos_sb_info *sbi =MSDOS_SB (sb);
fs/fat/inode.c static unsigned long calc_fat_clusters(struct super_block *sb) · line 1313
Quoted 10 lines
fs/fat/inode.c +2
-5/* Divide first to avoid overflow */ -if (sbi->fat_bits !=12 ) { -unsigned long ent_per_sec = sb->s_blocksize *8 / sbi->fat_bits; -return ent_per_sec * sbi->fat_length; - } +unsigned long ent_per_sec = sb->s_blocksize *8 / sbi->fat_bits; -return sbi->fat_length * sb->s_blocksize *8 / sbi->fat_bits; +return ent_per_sec * sbi->fat_length; }
When sbi->fat_bits == 12, it doesn't work, right? (there is the remainder)
Thanks.
Signature · 1 line
OGAWA Hirofumi <[email protected]>
Quoted 16 lines · OGAWA Hirofumi
Quoted 14 lines · Seunghun Lee
fs/fat/inode.c +1
-4@@ -1307,12 +1307,9 @@ static unsigned long calc_fat_clusters(struct super_block *sb)struct msdos_sb_info *sbi =MSDOS_SB (sb);/* Divide first to avoid overflow */ -if (sbi->fat_bits !=12 ) { -unsigned long ent_per_sec = sb->s_blocksize *8 / sbi->fat_bits; -return ent_per_sec * sbi->fat_length; - } +unsigned long ent_per_sec = sb->s_blocksize *8 / sbi->fat_bits;
Quoted 6 lines
fs/fat/inode.c static unsigned long calc_fat_clusters(struct super_block *sb) · line 1313
Quoted 3 lines
fs/fat/inode.c +1
-1-return sbi->fat_length * sb->s_blocksize *8 / sbi->fat_bits; +return ent_per_sec * sbi->fat_length; }When
sbi->fat_bits== 12, it doesn't work, right? (there is the remainder)Thanks.
Yes, you are right.
I didn't think about the remainder.
Thanks.