Skip to content

Commit

Permalink
gpio: htc-egpio: add .get_direction() support
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Linus Walleij committed Nov 12, 2016
1 parent c82064f commit 9298539
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions drivers/gpio/gpio-htc-egpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 9298539

Please sign in to comment.