diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2016-09-19 04:08:56 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2016-09-19 04:08:56 -0400 |
commit | 14063d71e5e6775c676755612fc81deb029685c4 (patch) | |
tree | 9b31f7c8e1076dd775c05a94ceb3b66718bbd4c1 | |
parent | 35a26144a193536eb8870de99ff4b7093b7879a3 (diff) |
gpio: tc3589x: add .get_direction() and small cleanup
This adds a .get_direction() callback to the TC3589x and
renames the function for setting single-ended mode to be
more to the point.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | drivers/gpio/gpio-tc3589x.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/drivers/gpio/gpio-tc3589x.c b/drivers/gpio/gpio-tc3589x.c index 5baa45768ec5..537a4335ddec 100644 --- a/drivers/gpio/gpio-tc3589x.c +++ b/drivers/gpio/gpio-tc3589x.c | |||
@@ -84,9 +84,25 @@ static int tc3589x_gpio_direction_input(struct gpio_chip *chip, | |||
84 | return tc3589x_set_bits(tc3589x, reg, BIT(pos), 0); | 84 | return tc3589x_set_bits(tc3589x, reg, BIT(pos), 0); |
85 | } | 85 | } |
86 | 86 | ||
87 | static int tc3589x_gpio_single_ended(struct gpio_chip *chip, | 87 | static int tc3589x_gpio_get_direction(struct gpio_chip *chip, |
88 | unsigned offset, | 88 | unsigned offset) |
89 | enum single_ended_mode mode) | 89 | { |
90 | struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(chip); | ||
91 | struct tc3589x *tc3589x = tc3589x_gpio->tc3589x; | ||
92 | u8 reg = TC3589x_GPIODIR0 + offset / 8; | ||
93 | unsigned pos = offset % 8; | ||
94 | int ret; | ||
95 | |||
96 | ret = tc3589x_reg_read(tc3589x, reg); | ||
97 | if (ret < 0) | ||
98 | return ret; | ||
99 | |||
100 | return !!(ret & BIT(pos)); | ||
101 | } | ||
102 | |||
103 | static int tc3589x_gpio_set_single_ended(struct gpio_chip *chip, | ||
104 | unsigned offset, | ||
105 | enum single_ended_mode mode) | ||
90 | { | 106 | { |
91 | struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(chip); | 107 | struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(chip); |
92 | struct tc3589x *tc3589x = tc3589x_gpio->tc3589x; | 108 | struct tc3589x *tc3589x = tc3589x_gpio->tc3589x; |
@@ -127,11 +143,12 @@ static int tc3589x_gpio_single_ended(struct gpio_chip *chip, | |||
127 | static const struct gpio_chip template_chip = { | 143 | static const struct gpio_chip template_chip = { |
128 | .label = "tc3589x", | 144 | .label = "tc3589x", |
129 | .owner = THIS_MODULE, | 145 | .owner = THIS_MODULE, |
130 | .direction_input = tc3589x_gpio_direction_input, | ||
131 | .get = tc3589x_gpio_get, | 146 | .get = tc3589x_gpio_get, |
132 | .direction_output = tc3589x_gpio_direction_output, | ||
133 | .set = tc3589x_gpio_set, | 147 | .set = tc3589x_gpio_set, |
134 | .set_single_ended = tc3589x_gpio_single_ended, | 148 | .direction_output = tc3589x_gpio_direction_output, |
149 | .direction_input = tc3589x_gpio_direction_input, | ||
150 | .get_direction = tc3589x_gpio_get_direction, | ||
151 | .set_single_ended = tc3589x_gpio_set_single_ended, | ||
135 | .can_sleep = true, | 152 | .can_sleep = true, |
136 | }; | 153 | }; |
137 | 154 | ||