]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kfifo: add kfifo_initialized
authorAndi Kleen <andi@firstfloor.org>
Sat, 16 Jan 2010 01:01:17 +0000 (17:01 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 16 Jan 2010 20:15:38 +0000 (12:15 -0800)
Simple inline that checks if kfifo_init() has been executed on a fifo.

This is useful for walking all per CPU fifos, when some of them might not
have been brought up yet.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Stefani Seibold <stefani@seibold.net>
Cc: Roland Dreier <rdreier@cisco.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Andy Walls <awalls@radix.net>
Cc: Vikram Dhillon <dhillonv10@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/kfifo.h

index 7ad6d32dd673d19b1a789bab112d81b5fdce7a3f..c8618243ca5a0bf9388c7d1edec975a597b54c45 100644 (file)
@@ -116,6 +116,16 @@ extern __must_check unsigned int kfifo_out(struct kfifo *fifo,
 extern __must_check unsigned int kfifo_out_peek(struct kfifo *fifo,
                                void *to, unsigned int len, unsigned offset);
 
+/**
+ * kfifo_initialized - Check if kfifo is initialized.
+ * @fifo: fifo to check
+ * Return %true if FIFO is initialized, otherwise %false.
+ * Assumes the fifo was 0 before.
+ */
+static inline bool kfifo_initialized(struct kfifo *fifo)
+{
+       return fifo->buffer != 0;
+}
 
 /**
  * kfifo_reset - removes the entire FIFO contents