gpio: rcar: Implement .get_direction() callback
authorGeert Uytterhoeven <geert+renesas@glider.be>
Thu, 12 Jul 2018 09:15:01 +0000 (11:15 +0200)
committerLinus Walleij <linus.walleij@linaro.org>
Fri, 13 Jul 2018 08:55:26 +0000 (10:55 +0200)
Allow gpiolib to read back the current I/O direction configuration by
implementing the .get_direction() callback.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-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/gpio-rcar.c

index 2c9a4fc92dc642353a48dfb2f418096dc3447ac0..55cc61086d99d10c8921320abe3e3e9c69bdacd7 100644 (file)
@@ -278,6 +278,13 @@ static void gpio_rcar_free(struct gpio_chip *chip, unsigned offset)
        pm_runtime_put(&p->pdev->dev);
 }
 
+static int gpio_rcar_get_direction(struct gpio_chip *chip, unsigned int offset)
+{
+       struct gpio_rcar_priv *p = gpiochip_get_data(chip);
+
+       return !(gpio_rcar_read(p, INOUTSEL) & BIT(offset));
+}
+
 static int gpio_rcar_direction_input(struct gpio_chip *chip, unsigned offset)
 {
        gpio_rcar_config_general_input_output_mode(chip, offset, false);
@@ -461,6 +468,7 @@ static int gpio_rcar_probe(struct platform_device *pdev)
        gpio_chip = &p->gpio_chip;
        gpio_chip->request = gpio_rcar_request;
        gpio_chip->free = gpio_rcar_free;
+       gpio_chip->get_direction = gpio_rcar_get_direction;
        gpio_chip->direction_input = gpio_rcar_direction_input;
        gpio_chip->get = gpio_rcar_get;
        gpio_chip->direction_output = gpio_rcar_direction_output;