]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
gpio: wcove-gpio: add get_direction method
authorBin Gao <bin.gao@linux.intel.com>
Mon, 15 Aug 2016 18:03:23 +0000 (11:03 -0700)
committerLinus Walleij <linus.walleij@linaro.org>
Fri, 19 Aug 2016 13:02:19 +0000 (15:02 +0200)
This patch adds .get_direction method for the gpio_chip structure
of the wcove_gpio driver.

Signed-off-by: Bin Gao <bin.gao@intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-wcove.c

index f5c88df96eaaf2f882d30b516f46af304f4deea3..e11d6a3fb641bde5078c827d723c07c7adbb9b3a 100644 (file)
@@ -164,6 +164,19 @@ static int wcove_gpio_dir_out(struct gpio_chip *chip, unsigned int gpio,
                            CTLO_OUTPUT_SET | value);
 }
 
+static int wcove_gpio_get_direction(struct gpio_chip *chip, unsigned int gpio)
+{
+       struct wcove_gpio *wg = gpiochip_get_data(chip);
+       unsigned int val;
+       int ret;
+
+       ret = regmap_read(wg->regmap, to_reg(gpio, CTRL_OUT), &val);
+       if (ret)
+               return ret;
+
+       return !(val & CTLO_DIR_OUT);
+}
+
 static int wcove_gpio_get(struct gpio_chip *chip, unsigned int gpio)
 {
        struct wcove_gpio *wg = gpiochip_get_data(chip);
@@ -394,6 +407,7 @@ static int wcove_gpio_probe(struct platform_device *pdev)
        wg->chip.label = KBUILD_MODNAME;
        wg->chip.direction_input = wcove_gpio_dir_in;
        wg->chip.direction_output = wcove_gpio_dir_out;
+       wg->chip.get_direction = wcove_gpio_get_direction;
        wg->chip.get = wcove_gpio_get;
        wg->chip.set = wcove_gpio_set;
        wg->chip.set_single_ended = wcove_gpio_set_single_ended,