Skip to contentSkip to conversation

pinctrl: lpass-lpi: implement .get_direction() for the GPIO driver

PATCH In review Bartosz Golaszewski 5 participants 5 messages Jan 26 – Jan 27

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

Fixes 6e261d1090d6 ("pinctrl: qcom: Add sm8250 lpass lpi pinctrl driver")
---
 drivers/pinctrl/qcom/pinctrl-lpass-lpi.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/pinctrl/qcom/pinctrl-lpass-lpi.c +17 -0
index 78212f992843..76aed3296279 100644
@@ -312,6 +312,22 @@ static const struct pinconf_ops lpi_gpio_pinconf_ops = {
 	.pin_config_group_set		= lpi_config_set,
 };
 
+static int lpi_gpio_get_direction(struct gpio_chip *chip, unsigned int pin)
+{
+	unsigned long config = pinconf_to_config_packed(PIN_CONFIG_LEVEL, 0);
+	struct lpi_pinctrl *state = gpiochip_get_data(chip);
+	unsigned long arg;
+	int ret;
+
+	ret = lpi_config_get(state->ctrl, pin, &config);
+	if (ret)
+		return ret;
+
+	arg = pinconf_to_config_argument(config);
+
+	return arg ? GPIO_LINE_DIRECTION_OUT : GPIO_LINE_DIRECTION_IN;
+}
+
 static int lpi_gpio_direction_input(struct gpio_chip *chip, unsigned int pin)
 {
 	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)
 #endif
 
 static const struct gpio_chip lpi_gpio_template = {
+	.get_direction		= lpi_gpio_get_direction,
 	.direction_input	= lpi_gpio_direction_input,
 	.direction_output	= lpi_gpio_direction_output,
 	.get			= lpi_gpio_get,
Signature · 1 line
2.47.3
Tested-by on v1 1/1
#1 lore raw
Quoted 8 lines · Bartosz Golaszewski

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.

Fixes 6e261d1090d6 ("pinctrl: qcom: Add sm8250 lpass lpi pinctrl driver")

Tested on Dell XPS13 9345 (x1e80100).

Reviewed-by Tested-by on v1 1/1
#2 lore raw
In reply to Bartosz Golaszewski
Quoted 9 lines · Bartosz Golaszewski

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.

Fixes 6e261d1090d6 ("pinctrl: qcom: Add sm8250 lpass lpi pinctrl driver")

---

Konrad

#3 lore raw
Quoted 6 lines · Konrad Dybcio
Quoted 4 lines · Bartosz Golaszewski

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.

Quoted 9 lines
Quoted 5 lines
Fixes 6e261d1090d6 ("pinctrl: qcom: Add sm8250 lpass lpi pinctrl driver")

---

Linus,

Just a heads-up: this is v6.19-rc8 material, as it got uncovered with GPIO changes in rc6.

Thanks,
Bartosz

maintainer
#4 lore raw
In reply to Bartosz Golaszewski
Quoted 8 lines · Bartosz Golaszewski

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.

Fixes 6e261d1090d6 ("pinctrl: qcom: Add sm8250 lpass lpi pinctrl driver")

Patch applied for fixes! Thanks for fixing this.

Yours,
Linus Walleij