Commit 1368c4f2482c9e06bcb297217433818b171cc9e3
Committed by
Linus Torvalds
1 parent
e1b5c1d3da
Exists in
master
and in
4 other branches
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: vignesh babu <vignesh.babu@wipro.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 2 additions and 1 deletions Side-by-side Diff
fs/block_dev.c
... | ... | @@ -22,6 +22,7 @@ |
22 | 22 | #include <linux/mount.h> |
23 | 23 | #include <linux/uio.h> |
24 | 24 | #include <linux/namei.h> |
25 | +#include <linux/log2.h> | |
25 | 26 | #include <asm/uaccess.h> |
26 | 27 | #include "internal.h" |
27 | 28 | |
... | ... | @@ -67,7 +68,7 @@ |
67 | 68 | int set_blocksize(struct block_device *bdev, int size) |
68 | 69 | { |
69 | 70 | /* Size must be a power of two, and between 512 and PAGE_SIZE */ |
70 | - if (size > PAGE_SIZE || size < 512 || (size & (size-1))) | |
71 | + if (size > PAGE_SIZE || size < 512 || !is_power_of_2(size)) | |
71 | 72 | return -EINVAL; |
72 | 73 | |
73 | 74 | /* Size cannot be smaller than the size supported by the device */ |