Skip to content

Commit 40daf04

Browse files
Bartosz Golaszewskigregkh
authored andcommitted
pinctrl: lpass-lpi: implement .get_direction() for the GPIO driver
[ Upstream commit 4f0d22e ] GPIO controller driver should typically implement the .get_direction() callback as GPIOLIB internals may try to use it to determine the state of a pin. Add it for the LPASS LPI driver. Reported-by: Abel Vesa <abelvesa@kernel.org> Cc: stable@vger.kernel.org Fixes: 6e261d1 ("pinctrl: qcom: Add sm8250 lpass lpi pinctrl driver") Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> Tested-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> # X1E CRD Tested-by: Abel Vesa <abel.vesa@oss.qualcomm.com> Signed-off-by: Linus Walleij <linusw@kernel.org> [ PIN_CONFIG_LEVEL => PIN_CONFIG_OUTPUT ] Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 69ada05 commit 40daf04

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

drivers/pinctrl/qcom/pinctrl-lpass-lpi.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,22 @@ static const struct pinconf_ops lpi_gpio_pinconf_ops = {
298298
.pin_config_group_set = lpi_config_set,
299299
};
300300

301+
static int lpi_gpio_get_direction(struct gpio_chip *chip, unsigned int pin)
302+
{
303+
unsigned long config = pinconf_to_config_packed(PIN_CONFIG_OUTPUT, 0);
304+
struct lpi_pinctrl *state = gpiochip_get_data(chip);
305+
unsigned long arg;
306+
int ret;
307+
308+
ret = lpi_config_get(state->ctrl, pin, &config);
309+
if (ret)
310+
return ret;
311+
312+
arg = pinconf_to_config_argument(config);
313+
314+
return arg ? GPIO_LINE_DIRECTION_OUT : GPIO_LINE_DIRECTION_IN;
315+
}
316+
301317
static int lpi_gpio_direction_input(struct gpio_chip *chip, unsigned int pin)
302318
{
303319
struct lpi_pinctrl *state = gpiochip_get_data(chip);
@@ -395,6 +411,7 @@ static void lpi_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
395411
#endif
396412

397413
static const struct gpio_chip lpi_gpio_template = {
414+
.get_direction = lpi_gpio_get_direction,
398415
.direction_input = lpi_gpio_direction_input,
399416
.direction_output = lpi_gpio_direction_output,
400417
.get = lpi_gpio_get,

0 commit comments

Comments
 (0)