Skip to contentSkip to conversation

pinctrl: mediatek: moore: implement gpio_chip::get_direction()

PATCH In review Bartosz Golaszewski 5 participants 10 messages Apr 10 – Apr 27

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

PATCH 1/1 pinctrl: mediatek: moore: implement gpio_chip::get_direction()

If the gpio_chip::get_direction() callback is not implemented by the GPIO controller driver, GPIOLIB emits a warning.

Implement get_direction() for the GPIO part of pinctrl-moore.

Fixes 471e998c0e31 ("gpiolib: remove redundant callback check")
Fixes e623c4303ed1 ("gpiolib: sanitize the return value of gpio_chip::get_direction()")
---
 drivers/pinctrl/mediatek/pinctrl-moore.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/pinctrl/mediatek/pinctrl-moore.c +18 -0
index 70f608347a5f6..071ba849e5322 100644
@@ -520,6 +520,23 @@ static int mtk_gpio_direction_output(struct gpio_chip *chip, unsigned int gpio,
 	return pinctrl_gpio_direction_output(chip, gpio);
 }
 
+static int mtk_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
+{
+	struct mtk_pinctrl *hw = gpiochip_get_data(chip);
+	const struct mtk_pin_desc *desc;
+	int ret, dir;
+
+	desc = (const struct mtk_pin_desc *)&hw->soc->pins[offset];
+	if (!desc->name)
+		return -ENOTSUPP;
+
+	ret = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DIR, &dir);
+	if (ret)
+		return ret;
+
+	return dir ? GPIO_LINE_DIRECTION_OUT : GPIO_LINE_DIRECTION_IN;
+}
+
 static int mtk_gpio_to_irq(struct gpio_chip *chip, unsigned int offset)
 {
 	struct mtk_pinctrl *hw = gpiochip_get_data(chip);
@@ -566,6 +583,7 @@ static int mtk_build_gpiochip(struct mtk_pinctrl *hw)
 	chip->parent		= hw->dev;
 	chip->request		= gpiochip_generic_request;
 	chip->free		= gpiochip_generic_free;
+	chip->get_direction	= mtk_gpio_get_direction;
 	chip->direction_input	= pinctrl_gpio_direction_input;
 	chip->direction_output	= mtk_gpio_direction_output;
 	chip->get		= mtk_gpio_get;
Signature · 1 line
2.47.3
maintainer
#1 lore raw
Quoted 10 lines · Bartosz Golaszewski

If the gpio_chip::get_direction() callback is not implemented by the GPIO controller driver, GPIOLIB emits a warning.

Implement get_direction() for the GPIO part of pinctrl-moore.

Fixes 471e998c0e31 ("gpiolib: remove redundant callback check")
Fixes e623c4303ed1 ("gpiolib: sanitize the return value of gpio_chip::get_direction()")

LGTM, but it would have to go into v7.1-rc1 right now due to timing, then from there to stable.

Yours,
Linus Walleij

#2 lore raw
In reply to Bartosz Golaszewski
Quoted 6 lines

Gesendet: Freitag, 10. April 2026 um 09:09
Von: "Bartosz Golaszewski" <[email protected]>
An: "Frank Wunderlich" <[email protected]>, "Sean Wang" <[email protected]>, "Linus Walleij" <[email protected]>, "Matthias Brugger" <[email protected]>, "AngeloGioacchino Del Regno" <[email protected]>, "Bartosz Golaszewski" <[email protected]>
CC: [email protected], [email protected], [email protected], [email protected], "Bartosz Golaszewski" <[email protected]>
Betreff: [PATCH] pinctrl: mediatek: moore: implement gpio_chip::get_direction()

Quoted 8 lines

If the gpio_chip::get_direction() callback is not implemented by the GPIO controller driver, GPIOLIB emits a warning.

Implement get_direction() for the GPIO part of pinctrl-moore.

Fixes 471e998c0e31 ("gpiolib: remove redundant callback check")
Fixes e623c4303ed1 ("gpiolib: sanitize the return value of gpio_chip::get_direction()")

please use the email i used for SoB in my linked patch (closes link below), the other email i use only for sending patches due to mail provider limitation.

regards Frank

Quoted 2 lines
#3 lore raw
Quoted 10 lines · Frank Wunderlich
Quoted 10 lines

Gesendet: Freitag, 10. April 2026 um 09:09
Von: "Bartosz Golaszewski" <[email protected]>
An: "Frank Wunderlich" <[email protected]>, "Sean Wang" <[email protected]>, "Linus Walleij" <[email protected]>, "Matthias Brugger" <[email protected]>, "AngeloGioacchino Del Regno" <[email protected]>, "Bartosz Golaszewski" <[email protected]>
CC: [email protected], [email protected], [email protected], [email protected], "Bartosz Golaszewski" <[email protected]>
Betreff: [PATCH] pinctrl: mediatek: moore: implement gpio_chip::get_direction()

If the gpio_chip::get_direction() callback is not implemented by the GPIO controller driver, GPIOLIB emits a warning.

Quoted 8 lines
Quoted 5 lines

Implement get_direction() for the GPIO part of pinctrl-moore.

Fixes 471e998c0e31 ("gpiolib: remove redundant callback check")
Fixes e623c4303ed1 ("gpiolib: sanitize the return value of gpio_chip::get_direction()")

please use the email i used for SoB in my linked patch (closes link below), the other email i use only for sending patches due to mail provider limitation.

Linus: Can you fix this when applying, please?

Frank: Can you also leave your Tested-by under the patch?

Thanks,
Bartosz

#4 lore raw
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines

please use the email i used for SoB in my linked patch (closes link below), the other email i use only for sending patches due to mail provider limitation.

Linus: Can you fix this when applying, please?

Frank: Can you also leave your Tested-by under the patch?

if my testcase is enough (just accessing /sys/kernel/debug/gpio via cat)

Quoted 2 lines

Thanks,
Bartosz

maintainer
#5 lore raw
In reply to Frank Wunderlich
Quoted 9 lines · Frank Wunderlich
Quoted 9 lines

Gesendet: Freitag, 10. April 2026 um 09:09
Von: "Bartosz Golaszewski" <[email protected]>
An: "Frank Wunderlich" <[email protected]>, "Sean Wang" <[email protected]>, "Linus Walleij" <[email protected]>, "Matthias Brugger" <[email protected]>, "AngeloGioacchino Del Regno" <[email protected]>, "Bartosz Golaszewski" <[email protected]>
CC: [email protected], [email protected], [email protected], [email protected], "Bartosz Golaszewski" <[email protected]>
Betreff: [PATCH] pinctrl: mediatek: moore: implement gpio_chip::get_direction()

If the gpio_chip::get_direction() callback is not implemented by the GPIO controller driver, GPIOLIB emits a warning.

Quoted 7 lines
Quoted 5 lines

Implement get_direction() for the GPIO part of pinctrl-moore.

Fixes 471e998c0e31 ("gpiolib: remove redundant callback check")
Fixes e623c4303ed1 ("gpiolib: sanitize the return value of gpio_chip::get_direction()")

please use the email i used for SoB in my linked patch (closes link below), the other email i use only for sending patches due to mail provider limitation.

I can't fix this up because the closes link isn't working right now. Is it the same
as the one this mail came from [email protected]?

Yours,
Linus Walleij

#6 lore raw

Am 13. April 2026 um 10:01 schrieb "Linus Walleij" <[email protected] mailto:[email protected]?to=%22Linus%20Walleij%22%20%3Clinusw%40kernel.org%3E >:

Quoted 20 lines
Quoted 16 lines · Frank Wunderlich

Gesendet: Freitag, 10. April 2026 um 09:09
Von: "Bartosz Golaszewski" <[email protected]>
An: "Frank Wunderlich" <[email protected]>, "Sean Wang" <[email protected]>, "Linus Walleij" <[email protected]>, "Matthias Brugger" <[email protected]>, "AngeloGioacchino Del Regno" <[email protected]>, "Bartosz Golaszewski" <[email protected]>
CC: [email protected], [email protected], [email protected], [email protected], "Bartosz Golaszewski" <[email protected]>
Betreff: [PATCH] pinctrl: mediatek: moore: implement gpio_chip::get_direction()

If the gpio_chip::get_direction() callback is not implemented by the GPIO controller driver, GPIOLIB emits a warning.

Implement get_direction() for the GPIO part of pinctrl-moore.

Fixes 471e998c0e31 ("gpiolib: remove redundant callback check")
Fixes e623c4303ed1 ("gpiolib: sanitize the return value of gpio_chip::get_direction()")
Quoted 5 lines
Quoted 2 lines

please use the email i used for SoB in my linked patch (closes link below), the other email i use only for sending patches due to mail provider limitation.

I can't fix this up because the closes link isn't working right now. Is it the same
as the one this mail came from [email protected]?

yes, closes-link works for me

Quoted 3 lines

Yours,
Linus Walleij

regards Frank

maintainer
#7 lore raw
Quoted 21 lines · Frank Wunderlich

Am 13. April 2026 um 10:01 schrieb "Linus Walleij" <[email protected] mailto:[email protected]?to=%22Linus%20Walleij%22%20%3Clinusw%40kernel.org%3E >:

Quoted 20 lines
Quoted 16 lines · Frank Wunderlich

Gesendet: Freitag, 10. April 2026 um 09:09
Von: "Bartosz Golaszewski" <[email protected]>
An: "Frank Wunderlich" <[email protected]>, "Sean Wang" <[email protected]>, "Linus Walleij" <[email protected]>, "Matthias Brugger" <[email protected]>, "AngeloGioacchino Del Regno" <[email protected]>, "Bartosz Golaszewski" <[email protected]>
CC: [email protected], [email protected], [email protected], [email protected], "Bartosz Golaszewski" <[email protected]>
Betreff: [PATCH] pinctrl: mediatek: moore: implement gpio_chip::get_direction()

If the gpio_chip::get_direction() callback is not implemented by the GPIO controller driver, GPIOLIB emits a warning.

Implement get_direction() for the GPIO part of pinctrl-moore.

Fixes 471e998c0e31 ("gpiolib: remove redundant callback check")
Fixes e623c4303ed1 ("gpiolib: sanitize the return value of gpio_chip::get_direction()")
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

please use the email i used for SoB in my linked patch (closes link below), the other email i use only for sending patches due to mail provider limitation.

I can't fix this up because the closes link isn't working right now. Is it the same
as the one this mail came from [email protected]?

yes, closes-link works for me

Fixed up and applied. Will be going in as fix for v7.1.

Yours,
Linus Walleij

#8 lore raw
Quoted 30 lines · Linus Walleij
Quoted 27 lines · Frank Wunderlich

Am 13. April 2026 um 10:01 schrieb "Linus Walleij" <[email protected] mailto:[email protected]?to=%22Linus%20Walleij%22%20%3Clinusw%40kernel.org%3E >:

Quoted 25 lines
Quoted 10 lines · Frank Wunderlich

Gesendet: Freitag, 10. April 2026 um 09:09
Von: "Bartosz Golaszewski" <[email protected]>
An: "Frank Wunderlich" <[email protected]>, "Sean Wang" <[email protected]>, "Linus Walleij" <[email protected]>, "Matthias Brugger" <[email protected]>, "AngeloGioacchino Del Regno" <[email protected]>, "Bartosz Golaszewski" <[email protected]>
CC: [email protected], [email protected], [email protected], [email protected], "Bartosz Golaszewski" <[email protected]>
Betreff: [PATCH] pinctrl: mediatek: moore: implement gpio_chip::get_direction()

If the gpio_chip::get_direction() callback is not implemented by the GPIO controller driver, GPIOLIB emits a warning.

Quoted 8 lines

Implement get_direction() for the GPIO part of pinctrl-moore.

Fixes 471e998c0e31 ("gpiolib: remove redundant callback check")
Fixes e623c4303ed1 ("gpiolib: sanitize the return value of gpio_chip::get_direction()")

please use the email i used for SoB in my linked patch (closes link below), the other email i use only for sending patches due to mail provider limitation.

I can't fix this up because the closes link isn't working right now. Is it the same
as the one this mail came from [email protected]?

Quoted 7 lines
Quoted 1 line

yes, closes-link works for me

Fixed up and applied. Will be going in as fix for v7.1.

Yours,
Linus Walleij

Hi Linus!

It seems this one got lost somewhere along the way? I don't see it in mainline nor next.

Bart

maintainer
#9 lore raw
Quoted 10 lines · Bartosz Golaszewski
Quoted 5 lines

Fixed up and applied. Will be going in as fix for v7.1.

Yours,
Linus Walleij

Hi Linus!

It seems this one got lost somewhere along the way? I don't see it in mainline nor next.

I'm just slow at pushing out my tree, it's on its way!

Yours,
Linus Walleij