Commit e7d709c0 authored by Vignesh Babu BM's avatar Vignesh Babu BM Committed by Linus Torvalds

is_power_of_2 in fat

Replacing (n & (n-1)) in the context of power of 2 checks with
is_power_of_2
Signed-off-by: default avatarvignesh babu <vignesh.babu@wipro.com>
Acked-by: default avatarOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 4fa156ea
......@@ -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
......@@ -1217,8 +1218,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)
......@@ -1228,8 +1228,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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment