Skip to content

Commit

Permalink
is_power_of_2: kernel/kfifo.c
Browse files Browse the repository at this point in the history
Replace (n & (n-1)) with is_power_of_2()

Signed-off-by: vignesh babu <[email protected]>
Acked-by: Stelian Pop <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
vignesh babu authored and Linus Torvalds committed Jul 16, 2007
1 parent cf99aba commit f84d5a7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion kernel/kfifo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit f84d5a7

Please sign in to comment.