[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200221154837.18845-3-brgl@bgdev.pl>
Date: Fri, 21 Feb 2020 16:48:34 +0100
From: Bartosz Golaszewski <brgl@...ev.pl>
To: Linus Walleij <linus.walleij@...aro.org>,
Srinivas Kandagatla <srinivas.kandagatla@...aro.org>,
Khouloud Touil <ktouil@...libre.com>,
Geert Uytterhoeven <geert@...ux-m68k.org>
Cc: linux-gpio@...r.kernel.org, linux-kernel@...r.kernel.org,
Bartosz Golaszewski <bgolaszewski@...libre.com>
Subject: [PATCH v5 2/5] gpiolib: provide VALIDATE_DESC_PTR() macro
From: Bartosz Golaszewski <bgolaszewski@...libre.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@...libre.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
Powered by blists - more mailing lists