All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fat: Simplify calc_fat_clusters code
@ 2014-09-02 13:33 Seunghun Lee
  2014-09-02 15:37 ` OGAWA Hirofumi
  0 siblings, 1 reply; 3+ messages in thread
From: Seunghun Lee @ 2014-09-02 13:33 UTC (permalink / raw)
  To: hirofumi; +Cc: linux-kernel, linux-fsdevel, Seunghun Lee

Code for fat12 and fat16/32 can be merged to one.

Signed-off-by: Seunghun Lee <waydi1@gmail.com>
---
 fs/fat/inode.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 756aead..6992dea 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -1307,12 +1307,9 @@ static unsigned long calc_fat_clusters(struct super_block *sb)
 	struct msdos_sb_info *sbi = MSDOS_SB(sb);
 
 	/* Divide first to avoid overflow */
-	if (sbi->fat_bits != 12) {
-		unsigned long ent_per_sec = sb->s_blocksize * 8 / sbi->fat_bits;
-		return ent_per_sec * sbi->fat_length;
-	}
+	unsigned long ent_per_sec = sb->s_blocksize * 8 / sbi->fat_bits;
 
-	return sbi->fat_length * sb->s_blocksize * 8 / sbi->fat_bits;
+	return ent_per_sec * sbi->fat_length;
 }
 
 static bool fat_bpb_is_zero(struct fat_boot_sector *b)
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] fat: Simplify calc_fat_clusters code
  2014-09-02 13:33 [PATCH] fat: Simplify calc_fat_clusters code Seunghun Lee
@ 2014-09-02 15:37 ` OGAWA Hirofumi
  2014-09-02 16:41   ` Seunghun Lee
  0 siblings, 1 reply; 3+ messages in thread
From: OGAWA Hirofumi @ 2014-09-02 15:37 UTC (permalink / raw)
  To: Seunghun Lee; +Cc: linux-kernel, linux-fsdevel

Seunghun Lee <waydi1@gmail.com> writes:

> diff --git a/fs/fat/inode.c b/fs/fat/inode.c
> index 756aead..6992dea 100644
> --- a/fs/fat/inode.c
> +++ b/fs/fat/inode.c
> @@ -1307,12 +1307,9 @@ static unsigned long calc_fat_clusters(struct super_block *sb)
>  	struct msdos_sb_info *sbi = MSDOS_SB(sb);
>  
>  	/* Divide first to avoid overflow */
> -	if (sbi->fat_bits != 12) {
> -		unsigned long ent_per_sec = sb->s_blocksize * 8 / sbi->fat_bits;
> -		return ent_per_sec * sbi->fat_length;
> -	}
> +	unsigned long ent_per_sec = sb->s_blocksize * 8 / sbi->fat_bits;
>  
> -	return sbi->fat_length * sb->s_blocksize * 8 / sbi->fat_bits;
> +	return ent_per_sec * sbi->fat_length;
>  }

When sbi->fat_bits == 12, it doesn't work, right? (there is the remainder)

Thanks.
-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] fat: Simplify calc_fat_clusters code
  2014-09-02 15:37 ` OGAWA Hirofumi
@ 2014-09-02 16:41   ` Seunghun Lee
  0 siblings, 0 replies; 3+ messages in thread
From: Seunghun Lee @ 2014-09-02 16:41 UTC (permalink / raw)
  To: OGAWA Hirofumi; +Cc: linux-kernel, linux-fsdevel


On 09/03/2014 12:37 AM, OGAWA Hirofumi wrote:
> Seunghun Lee <waydi1@gmail.com> writes:
>
>> diff --git a/fs/fat/inode.c b/fs/fat/inode.c
>> index 756aead..6992dea 100644
>> --- a/fs/fat/inode.c
>> +++ b/fs/fat/inode.c
>> @@ -1307,12 +1307,9 @@ static unsigned long calc_fat_clusters(struct super_block *sb)
>>  	struct msdos_sb_info *sbi = MSDOS_SB(sb);
>>  
>>  	/* Divide first to avoid overflow */
>> -	if (sbi->fat_bits != 12) {
>> -		unsigned long ent_per_sec = sb->s_blocksize * 8 / sbi->fat_bits;
>> -		return ent_per_sec * sbi->fat_length;
>> -	}
>> +	unsigned long ent_per_sec = sb->s_blocksize * 8 / sbi->fat_bits;
>>  
>> -	return sbi->fat_length * sb->s_blocksize * 8 / sbi->fat_bits;
>> +	return ent_per_sec * sbi->fat_length;
>>  }
> When sbi->fat_bits == 12, it doesn't work, right? (there is the remainder)
>
> Thanks.
Yes, you are right.

I didn't think about the remainder.

Thanks.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-09-02 16:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-02 13:33 [PATCH] fat: Simplify calc_fat_clusters code Seunghun Lee
2014-09-02 15:37 ` OGAWA Hirofumi
2014-09-02 16:41   ` Seunghun Lee

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.