summaryrefslogtreecommitdiff
path: root/fs/fat/fat.h
diff options
context:
space:
mode:
authorCarmeli Tamir <carmeli.tamir@gmail.com>2019-01-03 15:28:00 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2019-01-04 13:13:47 -0800
commit306790f75ac2fe021a900395255e468807002c42 (patch)
tree2099a8597d8214025191201bdd321b37a9419291 /fs/fat/fat.h
parentd19dc016187502dda6b8095e44eb46a18e89b2b3 (diff)
fat: new inline functions to determine the FAT variant (32, 16 or 12)
This patch introduces 3 new inline functions - is_fat12, is_fat16 and is_fat32, and replaces every occurrence in the code in which the FS variant (whether this is FAT12, FAT16 or FAT32) was previously checked using msdos_sb_info->fat_bits. Link: http://lkml.kernel.org/r/1544990640-11604-4-git-send-email-carmeli.tamir@gmail.com Signed-off-by: Carmeli Tamir <carmeli.tamir@gmail.com> Acked-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Cc: Johannes Thumshirn <jthumshirn@suse.de> Cc: Bart Van Assche <bvanassche@acm.org> Cc: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/fat/fat.h')
-rw-r--r--fs/fat/fat.h25
1 files changed, 22 insertions, 3 deletions
diff --git a/fs/fat/fat.h b/fs/fat/fat.h
index 979bb11832f6..922a0c6ba46c 100644
--- a/fs/fat/fat.h
+++ b/fs/fat/fat.h
@@ -142,13 +142,32 @@ static inline struct msdos_sb_info *MSDOS_SB(struct super_block *sb)
return sb->s_fs_info;
}
+/*
+ * Functions that determine the variant of the FAT file system (i.e.,
+ * whether this is FAT12, FAT16 or FAT32.
+ */
+static inline bool is_fat12(const struct msdos_sb_info *sbi)
+{
+ return sbi->fat_bits == 12;
+}
+
+static inline bool is_fat16(const struct msdos_sb_info *sbi)
+{
+ return sbi->fat_bits == 16;
+}
+
+static inline bool is_fat32(const struct msdos_sb_info *sbi)
+{
+ return sbi->fat_bits == 32;
+}
+
/* Maximum number of clusters */
static inline u32 max_fat(struct super_block *sb)
{
struct msdos_sb_info *sbi = MSDOS_SB(sb);
- return sbi->fat_bits == 32 ? MAX_FAT32 :
- sbi->fat_bits == 16 ? MAX_FAT16 : MAX_FAT12;
+ return is_fat32(sbi) ? MAX_FAT32 :
+ is_fat16(sbi) ? MAX_FAT16 : MAX_FAT12;
}
static inline struct msdos_inode_info *MSDOS_I(struct inode *inode)
@@ -266,7 +285,7 @@ static inline int fat_get_start(const struct msdos_sb_info *sbi,
const struct msdos_dir_entry *de)
{
int cluster = le16_to_cpu(de->start);
- if (sbi->fat_bits == 32)
+ if (is_fat32(sbi))
cluster |= (le16_to_cpu(de->starthi) << 16);
return cluster;
}