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 1/4] gpiolib: implement gpiod_set_value
Date: Wed,  2 Feb 2022 10:55:51 +0100	[thread overview]
Message-ID: <20220202095554.1103016-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20220202095554.1103016-1-a.fatoum@pengutronix.de>

Linux gpiod_set_value is silent if the GPIO descriptor is NULL, but
barebox warns about it. Also having gpio_set_value not respect active
low/high, while Linux gpiod_set_value respects it is error-prone.

Add a new gpiod_set_value function that covers this. gpio == -ENOENT is
taken as the dummy value for optional GPIOs.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 include/gpiod.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/include/gpiod.h b/include/gpiod.h
index c8b2cd47a3cb..adac50b4c36d 100644
--- a/include/gpiod.h
+++ b/include/gpiod.h
@@ -14,7 +14,7 @@ enum gpiod_flags {
 	GPIOD_IN	= GPIOF_IN,
 	/*
 	 * To change this later to a different logic level (i.e. taking
-	 * active low into account), use gpio_direction_active()
+	 * active low into account), use gpiod_set_value()
 	 */
 	GPIOD_OUT_LOW	= GPIOF_OUT_INIT_INACTIVE,
 	GPIOD_OUT_HIGH	= GPIOF_OUT_INIT_ACTIVE,
@@ -23,4 +23,10 @@ enum gpiod_flags {
 /* returned gpio descriptor can be passed to any normal gpio_* function */
 int gpiod_get(struct device_d *dev, const char *_con_id, enum gpiod_flags flags);
 
+static inline void gpiod_set_value(unsigned gpio, bool value)
+{
+	if (gpio != -ENOENT)
+		gpio_direction_active(gpio, value);
+}
+
 #endif
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


  reply	other threads:[~2022-02-02  9:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-02  9:55 [PATCH 0/4] video: add STM32F429-DISCO video pipeline support Ahmad Fatoum
2022-02-02  9:55 ` Ahmad Fatoum [this message]
2022-02-02  9:55 ` [PATCH 2/4] video: add driver for STM32 LCD-TFT Display Controller Ahmad Fatoum
2022-02-02  9:55 ` [PATCH 3/4] video: add MIPI DBI Type C Option 3 support Ahmad Fatoum
2022-02-03 14:30   ` Thorsten Scherer
2022-02-03 14:34     ` Ahmad Fatoum
2022-02-03 14:34   ` Thorsten Scherer
2022-02-03 16:37     ` Ahmad Fatoum
2022-02-02  9:55 ` [PATCH 4/4] video: add Ilitek ILI9341 panel support Ahmad Fatoum
  -- strict thread matches above, loose matches on Subject: below --
2022-01-31  8:02 [PATCH 0/4] video: add STM32F429-DISCO video pipeline support Ahmad Fatoum
2022-01-31  8:02 ` [PATCH 1/4] gpiolib: implement gpiod_set_value Ahmad Fatoum

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=20220202095554.1103016-2-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