From: stefani@seibold.net
To: linux-kernel@vger.kernel.org, akpm@linux-foundation.org
Cc: stefani@seibold.net
Subject: [PATCH 2/2] fix kfifo_alloc() and kfifo_init()
Date: Tue, 8 Jan 2013 22:36:21 +0100 [thread overview]
Message-ID: <1357680984-23007-3-git-send-email-stefani@seibold.net> (raw)
In-Reply-To: <1357680984-23007-1-git-send-email-stefani@seibold.net>
From: Stefani Seibold <stefani@seibold.net>
This patch fix the kfifo_alloc() and kfifo_init() to alloc at least the
requested number of elements. Since the kfifo operates on power of 2 the
request size will be rounded up to the next power of two.
Signed-off-by: Stefani Seibold <stefani@seibold.net>
---
lib/kfifo.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/lib/kfifo.c b/lib/kfifo.c
index 59dcf5b..7b7f830 100644
--- a/lib/kfifo.c
+++ b/lib/kfifo.c
@@ -42,8 +42,7 @@ int __kfifo_alloc(struct __kfifo *fifo, unsigned int size,
* round down to the next power of 2, since our 'let the indices
* wrap' technique works only in this case.
*/
- if (!is_power_of_2(size))
- size = rounddown_pow_of_two(size);
+ size = roundup_pow_of_two(size);
fifo->in = 0;
fifo->out = 0;
@@ -83,8 +82,7 @@ int __kfifo_init(struct __kfifo *fifo, void *buffer,
{
size /= esize;
- if (!is_power_of_2(size))
- size = rounddown_pow_of_two(size);
+ size = roundup_pow_of_two(size);
fifo->in = 0;
fifo->out = 0;
--
1.8.0.2
next prev parent reply other threads:[~2013-01-08 21:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-08 21:36 [PATCH 0/2] kfifo fixes stefani
2013-01-08 21:36 ` [PATCH 1/2] move kfifo.c from kernel/ to lib/ stefani
2013-01-08 21:36 ` stefani [this message]
2013-01-08 21:36 ` [PATCH 0/2] kfifo fixes stefani
2013-01-08 21:36 ` [PATCH 1/2] move kfifo.c from kernel/ to lib/ stefani
2013-01-08 21:36 ` [PATCH 2/2] fix kfifo_alloc() and kfifo_init() stefani
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1357680984-23007-3-git-send-email-stefani@seibold.net \
--to=stefani@seibold.net \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®