linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: linux-kernel@vger.kernel.org
Cc: Yuanhan Liu <yuanhan.liu@linux.intel.com>,
	Stefani Seibold <stefani@seibold.net>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH 4/5] kfifo: remove kfifo_init
Date: Tue,  8 Jan 2013 22:57:52 +0800	[thread overview]
Message-ID: <1357657073-27352-5-git-send-email-yuanhan.liu@linux.intel.com> (raw)
In-Reply-To: <1357657073-27352-1-git-send-email-yuanhan.liu@linux.intel.com>

kfifo_init is buggy, we should never use that. Instead, we should use
kfifo_alloc.

Cc: Stefani Seibold <stefani@seibold.net>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
---
 include/linux/kfifo.h |   27 ++-------------------------
 kernel/kfifo.c        |   23 -----------------------
 2 files changed, 2 insertions(+), 48 deletions(-)

diff --git a/include/linux/kfifo.h b/include/linux/kfifo.h
index 7a18245..4bf984e 100644
--- a/include/linux/kfifo.h
+++ b/include/linux/kfifo.h
@@ -27,14 +27,14 @@
  *
  * - Modify the declaration of the "struct kfifo *" object into a
  *   in-place "struct kfifo" object
- * - Init the in-place object with kfifo_alloc() or kfifo_init()
+ * - Init the in-place object with kfifo_alloc()
  *   Note: The address of the in-place "struct kfifo" object must be
  *   passed as the first argument to this functions
  * - Replace the use of __kfifo_put into kfifo_in and __kfifo_get
  *   into kfifo_out
  * - Replace the use of kfifo_put into kfifo_in_spinlocked and kfifo_get
  *   into kfifo_out_spinlocked
- *   Note: the spinlock pointer formerly passed to kfifo_init/kfifo_alloc
+ *   Note: the spinlock pointer formerly passed to kfifo_alloc
  *   must be passed now to the kfifo_in_spinlocked and kfifo_out_spinlocked
  *   as the last parameter
  * - The formerly __kfifo_* functions are renamed into kfifo_*
@@ -350,26 +350,6 @@ __kfifo_int_must_check_helper( \
 })
 
 /**
- * kfifo_init - initialize a fifo using a preallocated buffer
- * @fifo: the fifo to assign the buffer
- * @buffer: the preallocated buffer to be used
- * @size: the size of the internal buffer, this have to be a power of 2
- *
- * This macro initialize a fifo using a preallocated buffer.
- *
- * The numer of elements will be rounded-up to a power of 2.
- * Return 0 if no error, otherwise an error code.
- */
-#define kfifo_init(fifo, buffer, size) \
-({ \
-	typeof((fifo) + 1) __tmp = (fifo); \
-	struct __kfifo *__kfifo = &__tmp->kfifo; \
-	__is_kfifo_ptr(__tmp) ? \
-	__kfifo_init(__kfifo, buffer, size, sizeof(*__tmp->type)) : \
-	-EINVAL; \
-})
-
-/**
  * kfifo_put - put data into the fifo
  * @fifo: address of the fifo to be used
  * @val: the data to be added
@@ -770,9 +750,6 @@ extern int __kfifo_alloc(struct __kfifo *fifo, unsigned int size,
 
 extern void __kfifo_free(struct __kfifo *fifo);
 
-extern int __kfifo_init(struct __kfifo *fifo, void *buffer,
-	unsigned int size, size_t esize);
-
 extern unsigned int __kfifo_in(struct __kfifo *fifo,
 	const void *buf, unsigned int len);
 
diff --git a/kernel/kfifo.c b/kernel/kfifo.c
index 59dcf5b..d07f480 100644
--- a/kernel/kfifo.c
+++ b/kernel/kfifo.c
@@ -78,29 +78,6 @@ void __kfifo_free(struct __kfifo *fifo)
 }
 EXPORT_SYMBOL(__kfifo_free);
 
-int __kfifo_init(struct __kfifo *fifo, void *buffer,
-		unsigned int size, size_t esize)
-{
-	size /= esize;
-
-	if (!is_power_of_2(size))
-		size = rounddown_pow_of_two(size);
-
-	fifo->in = 0;
-	fifo->out = 0;
-	fifo->esize = esize;
-	fifo->data = buffer;
-
-	if (size < 2) {
-		fifo->mask = 0;
-		return -EINVAL;
-	}
-	fifo->mask = size - 1;
-
-	return 0;
-}
-EXPORT_SYMBOL(__kfifo_init);
-
 static void kfifo_copy_in(struct __kfifo *fifo, const void *src,
 		unsigned int len, unsigned int off)
 {
-- 
1.7.7.6


  parent reply	other threads:[~2013-01-08 14:57 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-08 14:57 [PATCH 0/5] kfifo cleanup and log based kfifo API Yuanhan Liu
2013-01-08 14:57 ` [PATCH 1/5] kfifo: remove unnecessary type check Yuanhan Liu
2013-01-08 21:51   ` Stefani Seibold
2013-01-09  2:35     ` Yuanhan Liu
2013-01-09 15:29       ` Stefani Seibold
2013-01-10  7:12         ` Yuanhan Liu
2013-01-08 14:57 ` [PATCH 2/5] libsrp: replace kfifo_init with kfifo_alloc Yuanhan Liu
2013-01-08 14:57 ` [PATCH 3/5] libiscsi: " Yuanhan Liu
2013-01-08 14:57 ` Yuanhan Liu [this message]
2013-01-08 14:57 ` [PATCH 5/5] kfifo: log based kfifo API Yuanhan Liu
2013-01-08 18:16   ` Dmitry Torokhov
2013-01-08 21:10     ` Andy Walls
2013-01-09  2:42     ` Yuanhan Liu
2013-01-08 15:03 ` Antw: [PATCH 0/5] kfifo cleanup and " Ulrich Windl
2013-01-08 15:29   ` Yuanhan Liu

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=1357657073-27352-5-git-send-email-yuanhan.liu@linux.intel.com \
    --to=yuanhan.liu@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stefani@seibold.net \
    /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;
as well as URLs for NNTP newsgroup(s).