From: Patrice Chotard Date: Thu, 20 Jun 2013 14:05:43 +0000 (+0200) Subject: pinctrl: abx500: fix abx500_gpio_get() X-Git-Tag: Ubuntu-snapdragon-4.4.0-1029.32~10625^2~13 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=d8d4f7f875bb8f94c52583a788e456eabbd6281a;p=mirror_ubuntu-zesty-kernel.git pinctrl: abx500: fix abx500_gpio_get() - allow to get output GPIO value - as there is no GPIO0 on ABX500, use correct offset with abx500_gpio_get_bit() Signed-off-by: Patrice Chotard Signed-off-by: Linus Walleij --- diff --git a/drivers/pinctrl/pinctrl-abx500.c b/drivers/pinctrl/pinctrl-abx500.c index caa7ab6811d1..d9d7ffc35c3e 100644 --- a/drivers/pinctrl/pinctrl-abx500.c +++ b/drivers/pinctrl/pinctrl-abx500.c @@ -162,10 +162,23 @@ static int abx500_gpio_get(struct gpio_chip *chip, unsigned offset) { struct abx500_pinctrl *pct = to_abx500_pinctrl(chip); bool bit; + bool is_out; + u8 gpio_offset = offset - 1; int ret; - ret = abx500_gpio_get_bit(chip, AB8500_GPIO_IN1_REG, - offset, &bit); + ret = abx500_gpio_get_bit(chip, AB8500_GPIO_DIR1_REG, + gpio_offset, &is_out); + if (ret < 0) { + dev_err(pct->dev, "%s failed\n", __func__); + return ret; + } + + if (is_out) + ret = abx500_gpio_get_bit(chip, AB8500_GPIO_OUT1_REG, + gpio_offset, &bit); + else + ret = abx500_gpio_get_bit(chip, AB8500_GPIO_IN1_REG, + gpio_offset, &bit); if (ret < 0) { dev_err(pct->dev, "%s failed\n", __func__); return ret;