gpio: ich: Implement get_direction function
diff mbox

Message ID 1061824414.20722.1427814707516.JavaMail.zimbra@xes-inc.com
State New
Headers show

Commit Message

Aaron Sierra March 31, 2015, 3:11 p.m. UTC
Allow the kernel to query the driver for a GPIO's pin direction.

Signed-off-by: Aaron Sierra <asierra@xes-inc.com>
---
 drivers/gpio/gpio-ich.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Linus Walleij April 8, 2015, 8:53 a.m. UTC | #1
On Tue, Mar 31, 2015 at 5:11 PM, Aaron Sierra <asierra@xes-inc.com> wrote:

> Allow the kernel to query the driver for a GPIO's pin direction.
>
> Signed-off-by: Aaron Sierra <asierra@xes-inc.com>

Patch applied.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
index 7818cd1..4ba7ed5 100644
--- a/drivers/gpio/gpio-ich.c
+++ b/drivers/gpio/gpio-ich.c
@@ -173,6 +173,11 @@  static bool ichx_gpio_check_available(struct gpio_chip *gpio, unsigned nr)
 	return !!(ichx_priv.use_gpio & (1 << (nr / 32)));
 }
 
+static int ichx_gpio_get_direction(struct gpio_chip *gpio, unsigned nr)
+{
+	return ichx_read_bit(GPIO_IO_SEL, nr) ? GPIOF_DIR_IN : GPIOF_DIR_OUT;
+}
+
 static int ichx_gpio_direction_input(struct gpio_chip *gpio, unsigned nr)
 {
 	/*
@@ -286,6 +291,7 @@  static void ichx_gpiolib_setup(struct gpio_chip *chip)
 		ichx_priv.desc->get : ichx_gpio_get;
 
 	chip->set = ichx_gpio_set;
+	chip->get_direction = ichx_gpio_get_direction;
 	chip->direction_input = ichx_gpio_direction_input;
 	chip->direction_output = ichx_gpio_direction_output;
 	chip->base = modparam_gpiobase;