From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 4/4] gpiolib: implement gpiod_get_value
Date: Mon, 9 Jan 2023 16:58:36 +0100 [thread overview]
Message-ID: <20230109155836.2220277-4-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20230109155836.2220277-1-a.fatoum@pengutronix.de>
The gpiod_ family of kernel functions always assume the logical state
for values (i.e. taking active low/high into account). We already have
gpio_set_value, so add gpiod_get_value for symmetry.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
include/gpiod.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/include/gpiod.h b/include/gpiod.h
index f76cc98155e0..8abf86db8682 100644
--- a/include/gpiod.h
+++ b/include/gpiod.h
@@ -63,4 +63,12 @@ static inline void gpiod_set_value(int gpio, bool value)
gpio_direction_active(gpio, value);
}
+static inline int gpiod_get_value(int gpio)
+{
+ if (gpio < 0)
+ return gpio;
+
+ return gpio_is_active(gpio);
+}
+
#endif
--
2.30.2
next prev parent reply other threads:[~2023-01-09 16:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-09 15:58 [PATCH 1/4] of: gpio: include <of.h> in <of_gpio.h> Ahmad Fatoum
2023-01-09 15:58 ` [PATCH 2/4] gpiolib: use signed int for gpio in gpiod_set_value Ahmad Fatoum
2023-01-09 15:58 ` [PATCH 3/4] gpiolib: implement dev_gpiod_get_index Ahmad Fatoum
2023-01-09 15:58 ` Ahmad Fatoum [this message]
2023-01-10 14:53 ` [PATCH 1/4] of: gpio: include <of.h> in <of_gpio.h> 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=20230109155836.2220277-4-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