LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [KJ][PATCH] is_power_of_2 in fs/block_dev.c
@ 2007-02-20  7:52 Vignesh Babu BM
  0 siblings, 0 replies; only message in thread
From: Vignesh Babu BM @ 2007-02-20  7:52 UTC (permalink / raw)
  To: Kernel Janitors List; +Cc: axboe, linux-kernel

Replacing (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>
--- 
diff --git a/fs/block_dev.c b/fs/block_dev.c
index fc7028b..e8f2a2b 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -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"
 
@@ -65,7 +66,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 */

-- 
Regards,  
Vignesh Babu BM  
_____________________________________________________________  
"Why is it that every time I'm with you, makes me believe in magic?"

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-02-20  7:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-20  7:52 [KJ][PATCH] is_power_of_2 in fs/block_dev.c Vignesh Babu BM

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).