aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2017-07-03 04:28:12 -0400
committerLinus Walleij <linus.walleij@linaro.org>2017-07-31 09:26:57 -0400
commitfa8f6d0619fa6775083fff24061e46e7039a8493 (patch)
tree1b6934ea31376c4fc3170a4d510608a4aac8c82a
parent727fd697da83bf78f8734940d0c394b6c7c3067f (diff)
gpio: lp87565: Set proper output level and direction for direction_output
The value argument of lp87565_gpio_direction_output() means output level rather than gpio direction. Signed-off-by: Axel Lin <axel.lin@ingics.com> Reviewed-by: Keerthy <j-keerthy@ti.com> Tested-by: Keerthy <j-keerthy@ti.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r--drivers/gpio/gpio-lp87565.c46
1 files changed, 24 insertions, 22 deletions
diff --git a/drivers/gpio/gpio-lp87565.c b/drivers/gpio/gpio-lp87565.c
index 6313c50bb91b..a121c8f10610 100644
--- a/drivers/gpio/gpio-lp87565.c
+++ b/drivers/gpio/gpio-lp87565.c
@@ -26,6 +26,27 @@ struct lp87565_gpio {
26 struct regmap *map; 26 struct regmap *map;
27}; 27};
28 28
29static int lp87565_gpio_get(struct gpio_chip *chip, unsigned int offset)
30{
31 struct lp87565_gpio *gpio = gpiochip_get_data(chip);
32 int ret, val;
33
34 ret = regmap_read(gpio->map, LP87565_REG_GPIO_IN, &val);
35 if (ret < 0)
36 return ret;
37
38 return !!(val & BIT(offset));
39}
40
41static void lp87565_gpio_set(struct gpio_chip *chip, unsigned int offset,
42 int value)
43{
44 struct lp87565_gpio *gpio = gpiochip_get_data(chip);
45
46 regmap_update_bits(gpio->map, LP87565_REG_GPIO_OUT,
47 BIT(offset), value ? BIT(offset) : 0);
48}
49
29static int lp87565_gpio_get_direction(struct gpio_chip *chip, 50static int lp87565_gpio_get_direction(struct gpio_chip *chip,
30 unsigned int offset) 51 unsigned int offset)
31{ 52{
@@ -54,30 +75,11 @@ static int lp87565_gpio_direction_output(struct gpio_chip *chip,
54{ 75{
55 struct lp87565_gpio *gpio = gpiochip_get_data(chip); 76 struct lp87565_gpio *gpio = gpiochip_get_data(chip);
56 77
78 lp87565_gpio_set(chip, offset, value);
79
57 return regmap_update_bits(gpio->map, 80 return regmap_update_bits(gpio->map,
58 LP87565_REG_GPIO_CONFIG, 81 LP87565_REG_GPIO_CONFIG,
59 BIT(offset), !value ? BIT(offset) : 0); 82 BIT(offset), BIT(offset));
60}
61
62static int lp87565_gpio_get(struct gpio_chip *chip, unsigned int offset)
63{
64 struct lp87565_gpio *gpio = gpiochip_get_data(chip);
65 int ret, val;
66
67 ret = regmap_read(gpio->map, LP87565_REG_GPIO_IN, &val);
68 if (ret < 0)
69 return ret;
70
71 return !!(val & BIT(offset));
72}
73
74static void lp87565_gpio_set(struct gpio_chip *chip, unsigned int offset,
75 int value)
76{
77 struct lp87565_gpio *gpio = gpiochip_get_data(chip);
78
79 regmap_update_bits(gpio->map, LP87565_REG_GPIO_OUT,
80 BIT(offset), value ? BIT(offset) : 0);
81} 83}
82 84
83static int lp87565_gpio_request(struct gpio_chip *gc, unsigned int offset) 85static int lp87565_gpio_request(struct gpio_chip *gc, unsigned int offset)