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

is_power_of_2 in fs/block_dev.c

Replace (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>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent e1b5c1d3
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <linux/mount.h> #include <linux/mount.h>
#include <linux/uio.h> #include <linux/uio.h>
#include <linux/namei.h> #include <linux/namei.h>
#include <linux/log2.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "internal.h" #include "internal.h"
...@@ -67,7 +68,7 @@ static void kill_bdev(struct block_device *bdev) ...@@ -67,7 +68,7 @@ static void kill_bdev(struct block_device *bdev)
int set_blocksize(struct block_device *bdev, int size) int set_blocksize(struct block_device *bdev, int size)
{ {
/* Size must be a power of two, and between 512 and PAGE_SIZE */ /* Size must be a power of two, and between 512 and PAGE_SIZE */
if (size > PAGE_SIZE || size < 512 || (size & (size-1))) if (size > PAGE_SIZE || size < 512 || !is_power_of_2(size))
return -EINVAL; return -EINVAL;
/* Size cannot be smaller than the size supported by the device */ /* Size cannot be smaller than the size supported by the device */
......
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