Re: [KJ][PATCH] is_power_of_2 in fat

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Vignesh Babu BM <[email protected]> writes:

> Replacing (n & (n-1)) in the context of power of 2 checks
> with is_power_of_2
>
> Signed-off-by: vignesh babu <[email protected]>

Acked-by: OGAWA Hirofumi <[email protected]>

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 <[email protected]>
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux