mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] gpiolib: implement gpiod_slice_acquired
Date: Mon, 15 Apr 2024 07:28:50 +0200	[thread overview]
Message-ID: <20240415052850.366859-1-a.fatoum@pengutronix.de> (raw)

For use by poller code that makes use of GPIO descriptors instead of the
unstable indices, add a gpiod variant of the existing
gpiod_slice_acquird.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/gpio/gpiolib.c        | 11 ++++++++---
 include/linux/gpio/consumer.h |  2 ++
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 5bc261a0105c..a70e13eafca2 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -172,16 +172,21 @@ int gpio_request(unsigned gpio, const char *label)
 	return gpiodesc_request(desc, label);
 }
 
-bool gpio_slice_acquired(unsigned gpio)
+bool gpiod_slice_acquired(struct gpio_desc *desc)
 {
-	struct gpio_desc *desc = gpio_to_desc(gpio);
-
 	if (!desc)
 		return false;
 
 	return slice_acquired(&desc->chip->slice);
 }
 
+bool gpio_slice_acquired(unsigned gpio)
+{
+	struct gpio_desc *desc = gpio_to_desc(gpio);
+
+	return gpiod_slice_acquired(desc);
+}
+
 static void gpiodesc_free(struct gpio_desc *desc)
 {
 	if (!desc->requested)
diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h
index 531ed1472546..e04f516b3155 100644
--- a/include/linux/gpio/consumer.h
+++ b/include/linux/gpio/consumer.h
@@ -45,6 +45,8 @@ struct gpio_descs {
 	DECLARE_FLEX_ARRAY(struct gpio_desc *, desc);
 };
 
+bool gpiod_slice_acquired(struct gpio_desc *);
+
 #if defined(CONFIG_OFDEVICE) && defined(CONFIG_GPIOLIB)
 
 /* returned gpio descriptor can be passed to any normal gpio_* function */
-- 
2.39.2




             reply	other threads:[~2024-04-15  5:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-15  5:28 Ahmad Fatoum [this message]
2024-04-16 10:30 ` Sascha Hauer

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=20240415052850.366859-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.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