From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Linus Walleij <linus.walleij@linaro.org>,
Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
Khouloud Touil <ktouil@baylibre.com>,
Geert Uytterhoeven <geert@linux-m68k.org>
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
Bartosz Golaszewski <bgolaszewski@baylibre.com>
Subject: [PATCH 1/3] gpiolib: provide VALIDATE_DESC_PTR() macro
Date: Mon, 24 Feb 2020 10:41:56 +0100 [thread overview]
Message-ID: <20200224094158.28761-2-brgl@bgdev.pl> (raw)
In-Reply-To: <20200224094158.28761-1-brgl@bgdev.pl>
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
We're about to add a public GPIO function that takes a descriptor as
argument and returns a pointer. Add a corresponding macro wrapping the
validate_desc() function that returns an ERR_PTR() on error.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
drivers/gpio/gpiolib.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 4d0106ceeba7..da8ffd40aa97 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -2864,6 +2864,14 @@ static int validate_desc(const struct gpio_desc *desc, const char *func)
return; \
} while (0)
+#define VALIDATE_DESC_PTR(desc) do { \
+ int __valid = validate_desc(desc, __func__); \
+ if (__valid < 0) \
+ return ERR_PTR(__valid); \
+ if (__valid == 0) \
+ return NULL; \
+ } while (0)
+
int gpiod_request(struct gpio_desc *desc, const char *label)
{
int ret = -EPROBE_DEFER;
--
2.25.0
next prev parent reply other threads:[~2020-02-24 9:42 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-24 9:41 [PATCH 0/3] gpiolib: add reference counting to GPIO descriptors Bartosz Golaszewski
2020-02-24 9:41 ` Bartosz Golaszewski [this message]
2020-02-24 9:41 ` [PATCH 2/3] gpiolib: use kref in gpio_desc Bartosz Golaszewski
2020-03-05 16:49 ` Bartosz Golaszewski
2020-03-12 10:10 ` Linus Walleij
2020-03-12 18:24 ` Bartosz Golaszewski
2020-03-13 8:43 ` Linus Walleij
2020-03-13 15:04 ` Bartosz Golaszewski
2020-03-23 8:44 ` Bartosz Golaszewski
2020-03-25 11:16 ` Linus Walleij
2020-03-25 11:35 ` Bartosz Golaszewski
2020-03-12 10:35 ` Linus Walleij
2020-03-13 14:47 ` Bartosz Golaszewski
2020-03-26 20:50 ` Linus Walleij
2020-03-30 14:36 ` Bartosz Golaszewski
2020-05-14 13:42 ` Bartosz Golaszewski
2020-05-16 9:50 ` Linus Walleij
2020-02-24 9:41 ` [PATCH 3/3] nvmem: increase the reference count of a gpio passed over config 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=20200224094158.28761-2-brgl@bgdev.pl \
--to=brgl@bgdev.pl \
--cc=bgolaszewski@baylibre.com \
--cc=geert@linux-m68k.org \
--cc=ktouil@baylibre.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=srinivas.kandagatla@linaro.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
Powered by JetHome