Skip to content

Commit

Permalink
is_power_of_2 in fs/block_dev.c
Browse files Browse the repository at this point in the history
Replace (n & (n-1)) in the context of power of 2 checks with is_power_of_2

Signed-off-by: vignesh babu <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Vignesh Babu BM authored and Linus Torvalds committed May 8, 2007
1 parent e1b5c1d commit 1368c4f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/block_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <linux/mount.h>
#include <linux/uio.h>
#include <linux/namei.h>
#include <linux/log2.h>
#include <asm/uaccess.h>
#include "internal.h"

Expand Down Expand Up @@ -67,7 +68,7 @@ static void kill_bdev(struct block_device *bdev)
int set_blocksize(struct block_device *bdev, int 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;

/* Size cannot be smaller than the size supported by the device */
Expand Down

0 comments on commit 1368c4f

Please sign in to comment.