fs/fat: remove fat12_ent_blocknr and use fat_ent_blocknr instead
PATCH 1/1 fs/fat: remove fat12_ent_blocknr and use fat_ent_blocknr instead
There is only one difference between fat12_ent_blocknr and fat_ent_blocknr functions in bytes calculation. Let's add bits checking to fat_ent_blocknr instead code duplication.
--- fs/fat/fatent.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-)
fs/fat/fatent.c +7 -12
@@ -21,21 +21,16 @@ struct fatent_operations {static DEFINE_SPINLOCK (fat12_entry_lock); -static void fat12_ent_blocknr (struct super_block *sb,int entry, -int *offset,sector_t *blocknr) -{ -struct msdos_sb_info *sbi =MSDOS_SB (sb); -int bytes = entry + (entry >>1 ); -WARN_ON (entry <FAT_START_ENT || sbi->max_cluster <= entry); - *offset = bytes & (sb->s_blocksize -1 ); - *blocknr = sbi->fat_start + (bytes >> sb->s_blocksize_bits); -} -static void fat_ent_blocknr (struct super_block *sb,int entry,int *offset,sector_t *blocknr) {struct msdos_sb_info *sbi =MSDOS_SB (sb); -int bytes = (entry << sbi->fatent_shift); +int bytes; + +if (sbi->fat_bits ==12 ) + bytes = entry + (entry >>1 ); +else + bytes = (entry << sbi->fatent_shift);WARN_ON (entry <FAT_START_ENT || sbi->max_cluster <= entry); *offset = bytes & (sb->s_blocksize -1 ); *blocknr = sbi->fat_start + (bytes >> sb->s_blocksize_bits);
@@ -250,7 +245,7 @@ static int fat32_ent_next(struct fat_entry *fatent) }static struct fatent_operations fat12_ops = { - .ent_blocknr = fat12_ent_blocknr, + .ent_blocknr = fat_ent_blocknr, .ent_set_ptr = fat12_ent_set_ptr, .ent_bread = fat12_ent_bread, .ent_get = fat12_ent_get,
Signature · 1 line
2.3.0.80.g18d0fec
OGAWA Hirofumi
maintainerQuoted 3 lines · Alexander Kuleshov
There is only one difference between
fat12_ent_blocknrandfat_ent_blocknrfunctions in bytes calculation. Let's add bits checking tofat_ent_blocknrinstead code duplication.
I guess, fat12 (very small volume size) is uncommon to be used now, and there is no way to switch fat12 <= fat16/fat32 at runtime. It is why has special handler, i.e. avoid overhead to fat16/fat32 by fat12 code.
Thanks.
Signature · 1 line
OGAWA Hirofumi <[email protected]>
Quoted 3 lines
I guess, fat12 (very small volume size) is uncommon to be used now, and there is no way to switch fat12 <= fat16/fat32 at runtime. It is why has special handler, i.e. avoid overhead to fat16/fat32 by fat12 code.
Understand. Thank you for explanation.