From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Kent Gibson <warthog618@gmail.com>,
Linus Walleij <linus.walleij@linaro.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Andrew Morton <akpm@linux-foundation.org>,
Jiri Kosina <jkosina@suse.cz>,
Stefani Seibold <stefani@seibold.net>
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
Bartosz Golaszewski <bgolaszewski@baylibre.com>
Subject: [RESEND PATCH v5 2/7] kfifo: provide kfifo_is_empty_spinlocked()
Date: Thu, 23 Jan 2020 15:05:01 +0100 [thread overview]
Message-ID: <20200123140506.29275-3-brgl@bgdev.pl> (raw)
In-Reply-To: <20200123140506.29275-1-brgl@bgdev.pl>
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Provide two spinlocked versions of kfifo_is_empty() to be used with
spinlocked variants of kfifo_in() and kfifo_out().
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
include/linux/kfifo.h | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/include/linux/kfifo.h b/include/linux/kfifo.h
index 123c200ed7cb..86249476b57f 100644
--- a/include/linux/kfifo.h
+++ b/include/linux/kfifo.h
@@ -246,6 +246,37 @@ __kfifo_int_must_check_helper(int val)
__tmpq->kfifo.in == __tmpq->kfifo.out; \
})
+/**
+ * kfifo_is_empty_spinlocked - returns true if the fifo is empty using
+ * a spinlock for locking
+ * @fifo: address of the fifo to be used
+ * @lock: spinlock to be used for locking
+ */
+#define kfifo_is_empty_spinlocked(fifo, lock) \
+({ \
+ unsigned long __flags; \
+ bool __ret; \
+ spin_lock_irqsave(lock, __flags); \
+ __ret = kfifo_is_empty(fifo); \
+ spin_unlock_irqrestore(lock, __flags); \
+ __ret; \
+})
+
+/**
+ * kfifo_is_empty_spinlocked_noirqsave - returns true if the fifo is empty
+ * using a spinlock for locking, doesn't disable interrupts
+ * @fifo: address of the fifo to be used
+ * @lock: spinlock to be used for locking
+ */
+#define kfifo_is_empty_spinlocked_noirqsave(fifo, lock) \
+({ \
+ bool __ret; \
+ spin_lock(lock); \
+ __ret = kfifo_is_empty(fifo); \
+ spin_unlock(lock); \
+ __ret; \
+})
+
/**
* kfifo_is_full - returns true if the fifo is full
* @fifo: address of the fifo to be used
--
2.23.0
next prev parent reply other threads:[~2020-01-23 14:05 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-23 14:04 [RESEND PATCH v5 0/7] gpiolib: add an ioctl() for monitoring line status changes Bartosz Golaszewski
2020-01-23 14:05 ` [RESEND PATCH v5 1/7] kfifo: provide noirqsave variants of spinlocked in and out helpers Bartosz Golaszewski
2020-01-23 14:05 ` Bartosz Golaszewski [this message]
2020-01-23 14:05 ` [RESEND PATCH v5 3/7] gpiolib: rework the locking mechanism for lineevent kfifo Bartosz Golaszewski
2020-01-23 14:05 ` [RESEND PATCH v5 4/7] gpiolib: emit a debug message when adding events to a full kfifo Bartosz Golaszewski
2020-01-23 14:05 ` [RESEND PATCH v5 5/7] gpiolib: provide a dedicated function for setting lineinfo Bartosz Golaszewski
2020-01-23 14:05 ` [RESEND PATCH v5 6/7] gpiolib: add new ioctl() for monitoring changes in line info Bartosz Golaszewski
2020-01-23 14:49 ` Andy Shevchenko
2020-01-23 14:05 ` [RESEND PATCH v5 7/7] tools: gpio: implement gpio-watch Bartosz Golaszewski
2020-01-23 14:50 ` [RESEND PATCH v5 0/7] gpiolib: add an ioctl() for monitoring line status changes Andy Shevchenko
2020-01-23 15:24 ` Bartosz Golaszewski
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=20200123140506.29275-3-brgl@bgdev.pl \
--to=brgl@bgdev.pl \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bgolaszewski@baylibre.com \
--cc=gregkh@linuxfoundation.org \
--cc=jkosina@suse.cz \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stefani@seibold.net \
--cc=warthog618@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.