Skip to content

Commit 4f0d22e

Browse files
Bartosz Golaszewskilinusw
authored andcommitted
pinctrl: lpass-lpi: implement .get_direction() for the GPIO driver
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>
1 parent 304c3eb commit 4f0d22e

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
@@ -312,6 +312,22 @@ static const struct pinconf_ops lpi_gpio_pinconf_ops = {
312312
.pin_config_group_set = lpi_config_set,
313313
};
314314

315+
static int lpi_gpio_get_direction(struct gpio_chip *chip, unsigned int pin)
316+
{
317+
unsigned long config = pinconf_to_config_packed(PIN_CONFIG_LEVEL, 0);
318+
struct lpi_pinctrl *state = gpiochip_get_data(chip);
319+
unsigned long arg;
320+
int ret;
321+
322+
ret = lpi_config_get(state->ctrl, pin, &config);
323+
if (ret)
324+
return ret;
325+
326+
arg = pinconf_to_config_argument(config);
327+
328+
return arg ? GPIO_LINE_DIRECTION_OUT : GPIO_LINE_DIRECTION_IN;
329+
}
330+
315331
static int lpi_gpio_direction_input(struct gpio_chip *chip, unsigned int pin)
316332
{
317333
struct lpi_pinctrl *state = gpiochip_get_data(chip);
@@ -409,6 +425,7 @@ static void lpi_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
409425
#endif
410426

411427
static const struct gpio_chip lpi_gpio_template = {
428+
.get_direction = lpi_gpio_get_direction,
412429
.direction_input = lpi_gpio_direction_input,
413430
.direction_output = lpi_gpio_direction_output,
414431
.get = lpi_gpio_get,

0 commit comments

Comments
 (0)