Skip to content

Commit d19dc01

Browse files
carmeli-tamirtorvalds
authored andcommitted
fat: move MAX_FAT to fat.h and change it to inline function
MAX_FAT is useless in msdos_fs.h, since it uses the MSDOS_SB function that is defined in fat.h. So really, this macro can be only called from code that already includes fat.h. Hence, this patch moves it to fat.h, right after MSDOS_SB is defined. I also changed it to an inline function in order to save the double call to MSDOS_SB. This was suggested by [email protected] in the previous version. 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. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Carmeli Tamir <[email protected]> Acked-by: OGAWA Hirofumi <[email protected]> Reviewed-by: Sergey Senozhatsky <[email protected]> Cc: Bart Van Assche <[email protected]> Cc: Johannes Thumshirn <[email protected]> Cc: Martin K. Petersen <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent b553337 commit d19dc01

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

fs/fat/fat.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,15 @@ static inline struct msdos_sb_info *MSDOS_SB(struct super_block *sb)
142142
return sb->s_fs_info;
143143
}
144144

145+
/* Maximum number of clusters */
146+
static inline u32 max_fat(struct super_block *sb)
147+
{
148+
struct msdos_sb_info *sbi = MSDOS_SB(sb);
149+
150+
return sbi->fat_bits == 32 ? MAX_FAT32 :
151+
sbi->fat_bits == 16 ? MAX_FAT16 : MAX_FAT12;
152+
}
153+
145154
static inline struct msdos_inode_info *MSDOS_I(struct inode *inode)
146155
{
147156
return container_of(inode, struct msdos_inode_info, vfs_inode);

fs/fat/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1781,7 +1781,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
17811781
/* check that FAT table does not overflow */
17821782
fat_clusters = calc_fat_clusters(sb);
17831783
total_clusters = min(total_clusters, fat_clusters - FAT_START_ENT);
1784-
if (total_clusters > MAX_FAT(sb)) {
1784+
if (total_clusters > max_fat(sb)) {
17851785
if (!silent)
17861786
fat_msg(sb, KERN_ERR, "count of clusters too big (%u)",
17871787
total_clusters);

include/uapi/linux/msdos_fs.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@
6565
#define MAX_FAT12 0xFF4
6666
#define MAX_FAT16 0xFFF4
6767
#define MAX_FAT32 0x0FFFFFF6
68-
#define MAX_FAT(s) (MSDOS_SB(s)->fat_bits == 32 ? MAX_FAT32 : \
69-
MSDOS_SB(s)->fat_bits == 16 ? MAX_FAT16 : MAX_FAT12)
7068

7169
/* bad cluster mark */
7270
#define BAD_FAT12 0xFF7

0 commit comments

Comments
 (0)