All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gpiolib: use better errno if get_direction is not available
@ 2018-07-11 16:33 Wolfram Sang
  2018-07-11 17:24 ` Geert Uytterhoeven
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Wolfram Sang @ 2018-07-11 16:33 UTC (permalink / raw)
  To: linux-gpio
  Cc: linux-renesas-soc, Linus Walleij, Geert Uytterhoeven,
	Wolfram Sang

EINVAL is very generic, use ENOTSUPP in case the gpiochip does not
provide this function. While removing the assignment from the 'status'
variable, use better indentation in the declaration block.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---

I got puzzled by the EINVAL until I found out that gpio-rcar simply does not
implement it.

@Geert: any reason gpio-rcar is missing it? I would need it for the
i2c-gpio-fault-injector.

 drivers/gpio/gpiolib.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index e11a3bb03820..18719f64e80b 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -210,15 +210,15 @@ static int gpiochip_find_base(int ngpio)
  */
 int gpiod_get_direction(struct gpio_desc *desc)
 {
-	struct gpio_chip	*chip;
-	unsigned		offset;
-	int			status = -EINVAL;
+	struct gpio_chip *chip;
+	unsigned offset;
+	int status;
 
 	chip = gpiod_to_chip(desc);
 	offset = gpio_chip_hwgpio(desc);
 
 	if (!chip->get_direction)
-		return status;
+		return -ENOTSUPP;
 
 	status = chip->get_direction(chip, offset);
 	if (status > 0) {
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2018-09-14 14:06 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-11 16:33 [PATCH] gpiolib: use better errno if get_direction is not available Wolfram Sang
2018-07-11 17:24 ` Geert Uytterhoeven
2018-07-11 17:29   ` Wolfram Sang
2018-07-12 15:51 ` Wolfram Sang
2018-07-12 16:31   ` Wolfram Sang
2018-07-25 20:20   ` Wolfram Sang
2018-07-29 21:33     ` Linus Walleij
2018-09-11 12:03       ` Geert Uytterhoeven
2018-09-14  8:46         ` Linus Walleij
2018-09-14  8:52           ` Wolfram Sang
2018-07-13  8:01 ` Simon Horman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.