summaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpio-pca953x.c
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2017-03-22 15:11:11 +0100
committerLinus Walleij <linus.walleij@linaro.org>2017-03-23 10:40:13 +0100
commit66e57192319bdd5cc469288267764c6353c4f621 (patch)
tree86ce31fe12fd08c585e6132f47b68e13a5ce4a57 /drivers/gpio/gpio-pca953x.c
parentgpio: mvebu: use BIT macro instead of bit shifting (diff)
downloadlinux-66e57192319bdd5cc469288267764c6353c4f621.tar.xz
linux-66e57192319bdd5cc469288267764c6353c4f621.zip
gpio: pca953x: Introduce a long awaited ->get_direction()
Introduce ->get_direction() callback for the driver. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> [Removed use of GPIOF_DIR* flags] Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpio-pca953x.c')
-rw-r--r--drivers/gpio/gpio-pca953x.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index d44232aadb6c..782d9adb55b9 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -363,6 +363,21 @@ exit:
mutex_unlock(&chip->i2c_lock);
}
+static int pca953x_gpio_get_direction(struct gpio_chip *gc, unsigned off)
+{
+ struct pca953x_chip *chip = gpiochip_get_data(gc);
+ u32 reg_val;
+ int ret;
+
+ mutex_lock(&chip->i2c_lock);
+ ret = pca953x_read_single(chip, chip->regs->direction, &reg_val, off);
+ mutex_unlock(&chip->i2c_lock);
+ if (ret < 0)
+ return ret;
+
+ return !!(reg_val & (1u << (off % BANK_SZ)));
+}
+
static void pca953x_gpio_set_multiple(struct gpio_chip *gc,
unsigned long *mask, unsigned long *bits)
{
@@ -408,6 +423,7 @@ static void pca953x_setup_gpio(struct pca953x_chip *chip, int gpios)
gc->direction_output = pca953x_gpio_direction_output;
gc->get = pca953x_gpio_get_value;
gc->set = pca953x_gpio_set_value;
+ gc->get_direction = pca953x_gpio_get_direction;
gc->set_multiple = pca953x_gpio_set_multiple;
gc->can_sleep = true;