mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] kfifo fixes
@ 2013-01-08 21:36 stefani
  2013-01-08 21:36 ` [PATCH 1/2] move kfifo.c from kernel/ to lib/ stefani
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: stefani @ 2013-01-08 21:36 UTC (permalink / raw)
  To: linux-kernel, akpm; +Cc: stefani

From: Stefani Seibold <stefani@seibold.net>

As requested by Andrew Morton

- move the kfifo.c file from kernel/ to lib/ and
- fix the kfifo_alloc() and kfifo_init() to alloc at least the requested number of elements

Signed-off-by: Stefani Seibold <stefani@seibold.net>


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

* [PATCH 1/2] move kfifo.c from kernel/ to lib/
  2013-01-08 21:36 [PATCH 0/2] kfifo fixes stefani
@ 2013-01-08 21:36 ` stefani
  2013-01-08 21:36 ` [PATCH 2/2] fix kfifo_alloc() and kfifo_init() stefani
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: stefani @ 2013-01-08 21:36 UTC (permalink / raw)
  To: linux-kernel, akpm; +Cc: stefani

From: Stefani Seibold <stefani@seibold.net>

This patch move the kfifo.c file from kernel/ to lib/

Signed-off-by: Stefani Seibold <stefani@seibold.net>
---
 kernel/Makefile         | 2 +-
 lib/Makefile            | 2 +-
 {kernel => lib}/kfifo.c | 0
 3 files changed, 2 insertions(+), 2 deletions(-)
 rename {kernel => lib}/kfifo.c (100%)

diff --git a/kernel/Makefile b/kernel/Makefile
index 6c072b6..619c79b 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -7,7 +7,7 @@ obj-y     = fork.o exec_domain.o panic.o printk.o \
 	    sysctl.o sysctl_binary.o capability.o ptrace.o timer.o user.o \
 	    signal.o sys.o kmod.o workqueue.o pid.o task_work.o \
 	    rcupdate.o extable.o params.o posix-timers.o \
-	    kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \
+	    kthread.o wait.o sys_ni.o posix-cpu-timers.o mutex.o \
 	    hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \
 	    notifier.o ksysfs.o cred.o \
 	    async.o range.o groups.o lglock.o smpboot.o
diff --git a/lib/Makefile b/lib/Makefile
index 02ed6c0..d7946ff 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -23,7 +23,7 @@ lib-y	+= kobject.o klist.o
 obj-y += bcd.o div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \
 	 bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \
 	 string_helpers.o gcd.o lcm.o list_sort.o uuid.o flex_array.o \
-	 bsearch.o find_last_bit.o find_next_bit.o llist.o memweight.o
+	 bsearch.o find_last_bit.o find_next_bit.o llist.o memweight.o kfifo.o
 obj-y += kstrtox.o
 obj-$(CONFIG_TEST_KSTRTOX) += test-kstrtox.o
 
diff --git a/kernel/kfifo.c b/lib/kfifo.c
similarity index 100%
rename from kernel/kfifo.c
rename to lib/kfifo.c
-- 
1.8.0.2


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

* [PATCH 2/2] fix kfifo_alloc() and kfifo_init()
  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
  2013-01-08 21:36 ` [PATCH 0/2] kfifo fixes stefani
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: stefani @ 2013-01-08 21:36 UTC (permalink / raw)
  To: linux-kernel, akpm; +Cc: stefani

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


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

* [PATCH 0/2] kfifo fixes
  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
@ 2013-01-08 21:36 ` 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
  4 siblings, 0 replies; 6+ messages in thread
From: stefani @ 2013-01-08 21:36 UTC (permalink / raw)
  To: linux-kernel, akpm; +Cc: stefani

From: Stefani Seibold <stefani@seibold.net>

As requested by Andrew Morton

- move the kfifo.c file from kernel/ to lib/ and
- fix the kfifo_alloc() and kfifo_init() to alloc at least the requested number of elements

Signed-off-by: Stefani Seibold <stefani@seibold.net>


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

* [PATCH 1/2] move kfifo.c from kernel/ to lib/
  2013-01-08 21:36 [PATCH 0/2] kfifo fixes stefani
                   ` (2 preceding siblings ...)
  2013-01-08 21:36 ` [PATCH 0/2] kfifo fixes stefani
@ 2013-01-08 21:36 ` stefani
  2013-01-08 21:36 ` [PATCH 2/2] fix kfifo_alloc() and kfifo_init() stefani
  4 siblings, 0 replies; 6+ messages in thread
From: stefani @ 2013-01-08 21:36 UTC (permalink / raw)
  To: linux-kernel, akpm; +Cc: stefani

From: Stefani Seibold <stefani@seibold.net>

This patch move the kfifo.c file from kernel/ to lib/

Signed-off-by: Stefani Seibold <stefani@seibold.net>
---
 kernel/Makefile         | 2 +-
 lib/Makefile            | 2 +-
 {kernel => lib}/kfifo.c | 0
 3 files changed, 2 insertions(+), 2 deletions(-)
 rename {kernel => lib}/kfifo.c (100%)

diff --git a/kernel/Makefile b/kernel/Makefile
index 6c072b6..619c79b 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -7,7 +7,7 @@ obj-y     = fork.o exec_domain.o panic.o printk.o \
 	    sysctl.o sysctl_binary.o capability.o ptrace.o timer.o user.o \
 	    signal.o sys.o kmod.o workqueue.o pid.o task_work.o \
 	    rcupdate.o extable.o params.o posix-timers.o \
-	    kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \
+	    kthread.o wait.o sys_ni.o posix-cpu-timers.o mutex.o \
 	    hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \
 	    notifier.o ksysfs.o cred.o \
 	    async.o range.o groups.o lglock.o smpboot.o
diff --git a/lib/Makefile b/lib/Makefile
index 02ed6c0..d7946ff 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -23,7 +23,7 @@ lib-y	+= kobject.o klist.o
 obj-y += bcd.o div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \
 	 bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \
 	 string_helpers.o gcd.o lcm.o list_sort.o uuid.o flex_array.o \
-	 bsearch.o find_last_bit.o find_next_bit.o llist.o memweight.o
+	 bsearch.o find_last_bit.o find_next_bit.o llist.o memweight.o kfifo.o
 obj-y += kstrtox.o
 obj-$(CONFIG_TEST_KSTRTOX) += test-kstrtox.o
 
diff --git a/kernel/kfifo.c b/lib/kfifo.c
similarity index 100%
rename from kernel/kfifo.c
rename to lib/kfifo.c
-- 
1.8.0.2


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

* [PATCH 2/2] fix kfifo_alloc() and kfifo_init()
  2013-01-08 21:36 [PATCH 0/2] kfifo fixes stefani
                   ` (3 preceding siblings ...)
  2013-01-08 21:36 ` [PATCH 1/2] move kfifo.c from kernel/ to lib/ stefani
@ 2013-01-08 21:36 ` stefani
  4 siblings, 0 replies; 6+ messages in thread
From: stefani @ 2013-01-08 21:36 UTC (permalink / raw)
  To: linux-kernel, akpm; +Cc: stefani

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


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

end of thread, other threads:[~2013-01-08 21:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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®