linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH]is_power_of_2-kernel/kfifo.c
@ 2007-06-14 10:35 vignesh babu
  2007-06-14 21:09 ` [PATCH]is_power_of_2-kernel/kfifo.c Stelian Pop
  0 siblings, 1 reply; 2+ messages in thread
From: vignesh babu @ 2007-06-14 10:35 UTC (permalink / raw)
  To: stelian; +Cc: linux-kernel, Kernel Janitors List


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/kernel/kfifo.c b/kernel/kfifo.c
index cee4191..bc41ad0 100644
--- a/kernel/kfifo.c
+++ b/kernel/kfifo.c
@@ -24,6 +24,7 @@
 #include <linux/slab.h>
 #include <linux/err.h>
 #include <linux/kfifo.h>
+#include <linux/log2.h>
 
 /**
  * kfifo_init - allocates a new FIFO using a preallocated buffer
@@ -41,7 +42,7 @@ struct kfifo *kfifo_init(unsigned char *buffer, unsigned int size,
 	struct kfifo *fifo;
 
 	/* size must be a power of 2 */
-	BUG_ON(size & (size - 1));
+	BUG_ON(!is_power_of_2(size));
 
 	fifo = kmalloc(sizeof(struct kfifo), gfp_mask);
 	if (!fifo)

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH]is_power_of_2-kernel/kfifo.c
  2007-06-14 10:35 [PATCH]is_power_of_2-kernel/kfifo.c vignesh babu
@ 2007-06-14 21:09 ` Stelian Pop
  0 siblings, 0 replies; 2+ messages in thread
From: Stelian Pop @ 2007-06-14 21:09 UTC (permalink / raw)
  To: vignesh babu; +Cc: linux-kernel, Kernel Janitors List

On Thu, Jun 14, 2007 at 04:05:06PM +0530, vignesh babu wrote:
> 
> 
> 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>

Signed-off-by: Stelian Pop <stelian@popies.net>

Thanks,

Stelian.
-- 
Stelian Pop <stelian@popies.net>    

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-06-14 21:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-14 10:35 [PATCH]is_power_of_2-kernel/kfifo.c vignesh babu
2007-06-14 21:09 ` [PATCH]is_power_of_2-kernel/kfifo.c Stelian Pop

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).