[PATCH 1/2] fat: Moved macros that won't work without fat.h

From: Carmeli Tamir
Date: Mon Dec 10 2018 - 14:42:38 EST


Both FAT_FIRST_ENT and MAX_FAT are useless in msdos_fs.h, since they need the
MSDOS_SB function that is defined in fat.h. So really, both can be only called
from code that already includes fat.h.

Hence, this patch moves them to fat.h, right after MSDOS_SB is defined.
This patch is required for the next in the series, in which the variant (whether
this is FAT12, FAT16 or FAT32) checks are replaced with new macros.


Signed-off-by: Carmeli Tamir <carmeli.tamir@xxxxxxxxx>
---
fs/fat/fat.h | 22 +++++++++++++++++-----
include/uapi/linux/msdos_fs.h | 5 -----
2 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/fs/fat/fat.h b/fs/fat/fat.h
index 4e1b2f6..e06fdd3 100644
--- a/fs/fat/fat.h
+++ b/fs/fat/fat.h
@@ -106,6 +106,23 @@ struct msdos_sb_info {

#define FAT_CACHE_VALID 0 /* special case for valid cache */

+static inline struct msdos_sb_info *MSDOS_SB(struct super_block *sb)
+{
+ return sb->s_fs_info;
+}
+
+/*
+ * Definitions that depend on the variant of the FAT file system (i.e., whether
+ * this is FAT12, FAT16 or FAT32.
+ */
+
+#define FAT_FIRST_ENT(s, x) ((MSDOS_SB(s)->fat_bits == 32 ? 0x0FFFFF00 : \
+ MSDOS_SB(s)->fat_bits == 16 ? 0xFF00 : 0xF00) | (x))
+
+/* maximum number of clusters */
+#define MAX_FAT(s) (MSDOS_SB(s)->fat_bits == 32 ? MAX_FAT32 : \
+ MSDOS_SB(s)->fat_bits == 16 ? MAX_FAT16 : MAX_FAT12)
+
/*
* MS-DOS file system inode data in memory
*/
@@ -137,11 +154,6 @@ struct fat_slot_info {
struct buffer_head *bh;
};

-static inline struct msdos_sb_info *MSDOS_SB(struct super_block *sb)
-{
- return sb->s_fs_info;
-}
-
static inline struct msdos_inode_info *MSDOS_I(struct inode *inode)
{
return container_of(inode, struct msdos_inode_info, vfs_inode);
diff --git a/include/uapi/linux/msdos_fs.h b/include/uapi/linux/msdos_fs.h
index 1216e6c..a577389 100644
--- a/include/uapi/linux/msdos_fs.h
+++ b/include/uapi/linux/msdos_fs.h
@@ -58,9 +58,6 @@
#define MSDOS_DOT ". " /* ".", padded to MSDOS_NAME chars */
#define MSDOS_DOTDOT ".. " /* "..", padded to MSDOS_NAME chars */

-#define FAT_FIRST_ENT(s, x) ((MSDOS_SB(s)->fat_bits == 32 ? 0x0FFFFF00 : \
- MSDOS_SB(s)->fat_bits == 16 ? 0xFF00 : 0xF00) | (x))
-
/* start of data cluster's entry (number of reserved clusters) */
#define FAT_START_ENT 2

@@ -68,8 +65,6 @@
#define MAX_FAT12 0xFF4
#define MAX_FAT16 0xFFF4
#define MAX_FAT32 0x0FFFFFF6
-#define MAX_FAT(s) (MSDOS_SB(s)->fat_bits == 32 ? MAX_FAT32 : \
- MSDOS_SB(s)->fat_bits == 16 ? MAX_FAT16 : MAX_FAT12)

/* bad cluster mark */
#define BAD_FAT12 0xFF7
--
2.7.4