LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [KJ][PATCH] is_power_of_2 in fat
@ 2007-02-20  7:49 Vignesh Babu BM
  2007-02-20 13:12 ` OGAWA Hirofumi
  0 siblings, 1 reply; 2+ messages in thread
From: Vignesh Babu BM @ 2007-02-20  7:49 UTC (permalink / raw)
  To: Kernel Janitors List; +Cc: hirofumi, linux-kernel

Replacing (n & (n-1)) in the context of power of 2 checks
with is_power_of_2

Signed-off-by: vignesh babu <vignesh.babu@wipro.com>
--- 
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index a9e4688..8437190 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -25,6 +25,7 @@
 #include <linux/parser.h>
 #include <linux/uio.h>
 #include <linux/writeback.h>
+#include <linux/log2.h>
 #include <asm/unaligned.h>
 
 #ifndef CONFIG_FAT_DEFAULT_IOCHARSET
@@ -1216,8 +1217,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent,
 	}
 	logical_sector_size =
 		le16_to_cpu(get_unaligned((__le16 *)&b->sector_size));
-	if (!logical_sector_size
-	    || (logical_sector_size & (logical_sector_size - 1))
+	if (!is_power_of_2(logical_sector_size)
 	    || (logical_sector_size < 512)
 	    || (PAGE_CACHE_SIZE < logical_sector_size)) {
 		if (!silent)
@@ -1227,8 +1227,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent,
 		goto out_invalid;
 	}
 	sbi->sec_per_clus = b->sec_per_clus;
-	if (!sbi->sec_per_clus
-	    || (sbi->sec_per_clus & (sbi->sec_per_clus - 1))) {
+	if (!is_power_of_2(sbi->sec_per_clus)) {
 		if (!silent)
 			printk(KERN_ERR "FAT: bogus sectors per cluster %u\n",
 			       sbi->sec_per_clus);

-- 
Regards,  
Vignesh Babu BM  
_____________________________________________________________  
"Why is it that every time I'm with you, makes me believe in magic?"

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

* Re: [KJ][PATCH] is_power_of_2 in fat
  2007-02-20  7:49 [KJ][PATCH] is_power_of_2 in fat Vignesh Babu BM
@ 2007-02-20 13:12 ` OGAWA Hirofumi
  0 siblings, 0 replies; 2+ messages in thread
From: OGAWA Hirofumi @ 2007-02-20 13:12 UTC (permalink / raw)
  To: Vignesh Babu BM; +Cc: Kernel Janitors List, linux-kernel

Vignesh Babu BM <vignesh.babu@wipro.com> writes:

> Replacing (n & (n-1)) in the context of power of 2 checks
> with is_power_of_2
>
> Signed-off-by: vignesh babu <vignesh.babu@wipro.com>

Acked-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

Thanks.

> --- 
> diff --git a/fs/fat/inode.c b/fs/fat/inode.c
> index a9e4688..8437190 100644
> --- a/fs/fat/inode.c
> +++ b/fs/fat/inode.c
> @@ -25,6 +25,7 @@
>  #include <linux/parser.h>
>  #include <linux/uio.h>
>  #include <linux/writeback.h>
> +#include <linux/log2.h>
>  #include <asm/unaligned.h>
>  
>  #ifndef CONFIG_FAT_DEFAULT_IOCHARSET
> @@ -1216,8 +1217,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent,
>  	}
>  	logical_sector_size =
>  		le16_to_cpu(get_unaligned((__le16 *)&b->sector_size));
> -	if (!logical_sector_size
> -	    || (logical_sector_size & (logical_sector_size - 1))
> +	if (!is_power_of_2(logical_sector_size)
>  	    || (logical_sector_size < 512)
>  	    || (PAGE_CACHE_SIZE < logical_sector_size)) {
>  		if (!silent)
> @@ -1227,8 +1227,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent,
>  		goto out_invalid;
>  	}
>  	sbi->sec_per_clus = b->sec_per_clus;
> -	if (!sbi->sec_per_clus
> -	    || (sbi->sec_per_clus & (sbi->sec_per_clus - 1))) {
> +	if (!is_power_of_2(sbi->sec_per_clus)) {
>  		if (!silent)
>  			printk(KERN_ERR "FAT: bogus sectors per cluster %u\n",
>  			       sbi->sec_per_clus);
>
> -- 
-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

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

end of thread, other threads:[~2007-02-20 13:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-20  7:49 [KJ][PATCH] is_power_of_2 in fat Vignesh Babu BM
2007-02-20 13:12 ` OGAWA Hirofumi

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).