OSDN Git Service

gpiolib: use better errno if get_direction is not available
authorWolfram Sang <wsa+renesas@sang-engineering.com>
Wed, 11 Jul 2018 16:33:19 +0000 (18:33 +0200)
committerLinus Walleij <linus.walleij@linaro.org>
Fri, 14 Sep 2018 08:45:13 +0000 (10:45 +0200)
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>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpiolib.c

index 8fbaea5..74f3af2 100644 (file)
@@ -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) {