Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751931AbbBRTNM (ORCPT ); Wed, 18 Feb 2015 14:13:12 -0500 Received: from mail-lb0-f174.google.com ([209.85.217.174]:42922 "EHLO mail-lb0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750955AbbBRTNK (ORCPT ); Wed, 18 Feb 2015 14:13:10 -0500 From: Alexander Kuleshov To: OGAWA Hirofumi Cc: linux-kernel@vger.kernel.org, Alexander Kuleshov Subject: [PATCH] fs/fat: remove fat12_ent_blocknr and use fat_ent_blocknr instead Date: Thu, 19 Feb 2015 01:13:02 +0600 Message-Id: <1424286782-1726-1-git-send-email-kuleshovmail@gmail.com> X-Mailer: git-send-email 2.3.0.80.g18d0fec Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1958 Lines: 58 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. Signed-off-by: Alexander Kuleshov --- fs/fat/fatent.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/fs/fat/fatent.c b/fs/fat/fatent.c index 260705c..314ab50 100644 --- a/fs/fat/fatent.c +++ b/fs/fat/fatent.c @@ -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, -- 2.3.0.80.g18d0fec -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/