All of lore.kernel.org
 help / color / mirror / Atom feed
* [KJ] [PATCH] is_power_of_2 in kernel/kfifo
@ 2007-02-21 13:30 Vignesh Babu BM
  2007-02-21 15:32 ` Richard Knutsson
  2007-02-21 20:37 ` Stelian Pop
  0 siblings, 2 replies; 3+ messages in thread
From: Vignesh Babu BM @ 2007-02-21 13:30 UTC (permalink / raw)
  To: kernel-janitors

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 5d1d907..eeb5e7e 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)


-- 
Regards,  
Vignesh Babu BM  
_____________________________________________________________  
"Why is it that every time I'm with you, makes me believe in magic?"
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* Re: [KJ] [PATCH] is_power_of_2 in kernel/kfifo
  2007-02-21 13:30 [KJ] [PATCH] is_power_of_2 in kernel/kfifo Vignesh Babu BM
@ 2007-02-21 15:32 ` Richard Knutsson
  2007-02-21 20:37 ` Stelian Pop
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Knutsson @ 2007-02-21 15:32 UTC (permalink / raw)
  To: kernel-janitors

Vignesh Babu BM 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>
> --- 
> diff --git a/kernel/kfifo.c b/kernel/kfifo.c
> index 5d1d907..eeb5e7e 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)
>   
Could you also remove the comment? (since it is now obvious by the code)

Richard Knutsson

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* Re: [KJ] [PATCH] is_power_of_2 in kernel/kfifo
  2007-02-21 13:30 [KJ] [PATCH] is_power_of_2 in kernel/kfifo Vignesh Babu BM
  2007-02-21 15:32 ` Richard Knutsson
@ 2007-02-21 20:37 ` Stelian Pop
  1 sibling, 0 replies; 3+ messages in thread
From: Stelian Pop @ 2007-02-21 20:37 UTC (permalink / raw)
  To: kernel-janitors

Le mercredi 21 février 2007 à 16:32 +0100, Richard Knutsson a écrit :
> Vignesh Babu BM 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>
[...]
> > -	BUG_ON(size & (size - 1));
> > +	BUG_ON(!is_power_of_2(size));
[...]
> Could you also remove the comment? (since it is now obvious by the code)

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

Thanks,

-- 
Stelian Pop <stelian@popies.net>

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

end of thread, other threads:[~2007-02-21 20:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-21 13:30 [KJ] [PATCH] is_power_of_2 in kernel/kfifo Vignesh Babu BM
2007-02-21 15:32 ` Richard Knutsson
2007-02-21 20:37 ` Stelian Pop

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.