* [PATCH] gpiolib: implement gpiod_slice_acquired
@ 2024-04-15 5:28 Ahmad Fatoum
2024-04-16 10:30 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2024-04-15 5:28 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-04-16 10:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-15 5:28 [PATCH] gpiolib: implement gpiod_slice_acquired Ahmad Fatoum
2024-04-16 10:30 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox