summaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2016-11-12 14:36:17 +0100
committerLinus Walleij <linus.walleij@linaro.org>2016-11-12 14:36:17 +0100
commit9298539c0472c1bd7516c62d444e561493e3f26c (patch)
tree44af6fd71702f3f65936c5a4a591a5eb28fc8ece /drivers/gpio
parentc82064f26f44ea13f097dfb58d5ffd4359dcabbb (diff)
downloadlinux-9298539c0472c1bd7516c62d444e561493e3f26c.tar.bz2
gpio: htc-egpio: add .get_direction() support
This makes is possible to read out the current direction of a GPIO line on the HTC CPLD GPIO expander. Suggested-by: Russell King <linux@arm.linux.org.uk> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/gpio-htc-egpio.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/gpio/gpio-htc-egpio.c b/drivers/gpio/gpio-htc-egpio.c
index 5ab895b41819..27af52850927 100644
--- a/drivers/gpio/gpio-htc-egpio.c
+++ b/drivers/gpio/gpio-htc-egpio.c
@@ -225,6 +225,15 @@ static int egpio_direction_output(struct gpio_chip *chip,
}
}
+static int egpio_get_direction(struct gpio_chip *chip, unsigned offset)
+{
+ struct egpio_chip *egpio;
+
+ egpio = gpiochip_get_data(chip);
+
+ return !test_bit(offset, &egpio->is_out);
+}
+
static void egpio_write_cache(struct egpio_info *ei)
{
int i;
@@ -327,6 +336,7 @@ static int __init egpio_probe(struct platform_device *pdev)
chip->set = egpio_set;
chip->direction_input = egpio_direction_input;
chip->direction_output = egpio_direction_output;
+ chip->get_direction = egpio_get_direction;
chip->base = pdata->chip[i].gpio_base;
chip->ngpio = pdata->chip[i].num_gpios;