From: Alexander Kuleshov <kuleshovmail@gmail.com>
To: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Cc: linux-kernel@vger.kernel.org,
Alexander Kuleshov <kuleshovmail@gmail.com>
Subject: [PATCH] fs/fat: remove fat12_ent_blocknr and use fat_ent_blocknr instead
Date: Thu, 19 Feb 2015 01:13:02 +0600 [thread overview]
Message-ID: <1424286782-1726-1-git-send-email-kuleshovmail@gmail.com> (raw)
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 <kuleshovmail@gmail.com>
---
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
next reply other threads:[~2015-02-18 19:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-18 19:13 Alexander Kuleshov [this message]
2015-02-18 19:23 ` OGAWA Hirofumi
2015-02-18 19:49 ` Alexander Kuleshov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1424286782-1726-1-git-send-email-kuleshovmail@gmail.com \
--to=kuleshovmail@gmail.com \
--cc=hirofumi@mail.parknet.co.jp \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®