Skip to content

Commit f84d5a7

Browse files
vignesh babuLinus Torvalds
authored andcommitted
is_power_of_2: kernel/kfifo.c
Replace (n & (n-1)) with is_power_of_2() Signed-off-by: vignesh babu <vignesh.babu@wipro.com> Acked-by: Stelian Pop <stelian@popies.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent cf99aba commit f84d5a7

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎kernel/kfifo.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/slab.h>
2525
#include <linux/err.h>
2626
#include <linux/kfifo.h>
27+
#include <linux/log2.h>
2728

2829
/**
2930
* kfifo_init - allocates a new FIFO using a preallocated buffer
@@ -41,7 +42,7 @@ struct kfifo *kfifo_init(unsigned char *buffer, unsigned int size,
4142
struct kfifo *fifo;
4243

4344
/* size must be a power of 2 */
44-
BUG_ON(size & (size - 1));
45+
BUG_ON(!is_power_of_2(size));
4546

4647
fifo = kmalloc(sizeof(struct kfifo), gfp_mask);
4748
if (!fifo)

0 commit comments

Comments
 (0)