linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Carmeli Tamir <carmeli.tamir@gmail.com>
To: carmeli.tamir@gmail.com, hirofumi@mail.parknet.co.jp,
	linux-kernel@vger.kernel.org, jthumshirn@suse.de,
	sergey.senozhatsky@gmail.com, akpm@linux-foundation.org,
	bvanassche@acm.org, axboe@kernel.dk, martin.petersen@oracle.com,
	sfr@canb.auug.org.au
Subject: [PATCH v3 2/3] fat: Moved MAX_FAT to fat.h and changed it to inline function
Date: Sun, 16 Dec 2018 15:03:59 -0500	[thread overview]
Message-ID: <1544990640-11604-3-git-send-email-carmeli.tamir@gmail.com> (raw)
In-Reply-To: <1544990640-11604-1-git-send-email-carmeli.tamir@gmail.com>

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 joe@perches.com 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.


Signed-off-by: Carmeli Tamir <carmeli.tamir@gmail.com>
---
 fs/fat/fat.h                  | 9 +++++++++
 fs/fat/inode.c                | 2 +-
 include/uapi/linux/msdos_fs.h | 2 --
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/fs/fat/fat.h b/fs/fat/fat.h
index 4e1b2f6..979bb11 100644
--- a/fs/fat/fat.h
+++ b/fs/fat/fat.h
@@ -142,6 +142,15 @@ static inline struct msdos_sb_info *MSDOS_SB(struct super_block *sb)
 	return sb->s_fs_info;
 }
 
+/* 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;
+}
+
 static inline struct msdos_inode_info *MSDOS_I(struct inode *inode)
 {
 	return container_of(inode, struct msdos_inode_info, vfs_inode);
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 708de6d..7ede9db 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -1782,7 +1782,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
 	/* check that FAT table does not overflow */
 	fat_clusters = calc_fat_clusters(sb);
 	total_clusters = min(total_clusters, fat_clusters - FAT_START_ENT);
-	if (total_clusters > MAX_FAT(sb)) {
+	if (total_clusters > max_fat(sb)) {
 		if (!silent)
 			fat_msg(sb, KERN_ERR, "count of clusters too big (%u)",
 			       total_clusters);
diff --git a/include/uapi/linux/msdos_fs.h b/include/uapi/linux/msdos_fs.h
index 833c707..a577389 100644
--- a/include/uapi/linux/msdos_fs.h
+++ b/include/uapi/linux/msdos_fs.h
@@ -65,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


  parent reply	other threads:[~2018-12-16 20:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-16 20:03 [PATCH v3 0/3] fat: Added functions to determine the FAT variant (12/16/32bit) Carmeli Tamir
2018-12-16 20:03 ` [PATCH v3 1/3] fat: Removed FAT_FIRST_ENT macro Carmeli Tamir
2018-12-16 20:03 ` Carmeli Tamir [this message]
2018-12-16 20:04 ` [PATCH v3 3/3] fat: New inline functions to determine the FAT variant (32, 16 or 12) Carmeli Tamir
2018-12-24 12:04 ` [PATCH v3 0/3] fat: Added functions to determine the FAT variant (12/16/32bit) OGAWA Hirofumi
2018-12-25  9:48   ` Sergey Senozhatsky

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=1544990640-11604-3-git-send-email-carmeli.tamir@gmail.com \
    --to=carmeli.tamir@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=hirofumi@mail.parknet.co.jp \
    --cc=jthumshirn@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=sergey.senozhatsky@gmail.com \
    --cc=sfr@canb.auug.org.au \
    /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;
as well as URLs for NNTP newsgroup(s).