public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] pinctrl: mediatek: moore: implement gpio_chip::get_direction()
@ 2026-04-10  7:09 Bartosz Golaszewski
  2026-04-10  7:37 ` Linus Walleij
  2026-04-10  9:24 ` Aw: " Frank Wunderlich
  0 siblings, 2 replies; 5+ messages in thread
From: Bartosz Golaszewski @ 2026-04-10  7:09 UTC (permalink / raw)
  To: Frank Wunderlich, Sean Wang, Linus Walleij, Matthias Brugger,
	AngeloGioacchino Del Regno, Bartosz Golaszewski
  Cc: linux-mediatek, linux-gpio, linux-kernel, linux-arm-kernel,
	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()")
Reported-by: Frank Wunderlich <linux@fw-web.de>
Closes: https://lore.kernel.org/all/20260409132724.126258-1-linux@fw-web.de/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/pinctrl/mediatek/pinctrl-moore.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/pinctrl/mediatek/pinctrl-moore.c b/drivers/pinctrl/mediatek/pinctrl-moore.c
index 70f608347a5f6..071ba849e5322 100644
--- a/drivers/pinctrl/mediatek/pinctrl-moore.c
+++ b/drivers/pinctrl/mediatek/pinctrl-moore.c
@@ -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;
-- 
2.47.3



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] pinctrl: mediatek: moore: implement gpio_chip::get_direction()
  2026-04-10  7:09 [PATCH] pinctrl: mediatek: moore: implement gpio_chip::get_direction() Bartosz Golaszewski
@ 2026-04-10  7:37 ` Linus Walleij
  2026-04-10  9:24 ` Aw: " Frank Wunderlich
  1 sibling, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2026-04-10  7:37 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Frank Wunderlich, Sean Wang, Matthias Brugger,
	AngeloGioacchino Del Regno, Bartosz Golaszewski, linux-mediatek,
	linux-gpio, linux-kernel, linux-arm-kernel

On Fri, Apr 10, 2026 at 9:09 AM Bartosz Golaszewski
<bartosz.golaszewski@oss.qualcomm.com> wrote:

> 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()")
> Reported-by: Frank Wunderlich <linux@fw-web.de>
> Closes: https://lore.kernel.org/all/20260409132724.126258-1-linux@fw-web.de/
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

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

Yours,
Linus Walleij


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Aw: [PATCH] pinctrl: mediatek: moore: implement gpio_chip::get_direction()
  2026-04-10  7:09 [PATCH] pinctrl: mediatek: moore: implement gpio_chip::get_direction() Bartosz Golaszewski
  2026-04-10  7:37 ` Linus Walleij
@ 2026-04-10  9:24 ` Frank Wunderlich
  2026-04-10  9:54   ` Bartosz Golaszewski
  1 sibling, 1 reply; 5+ messages in thread
From: Frank Wunderlich @ 2026-04-10  9:24 UTC (permalink / raw)
  To: bartosz.golaszewski, linux, sean.wang, linusw, matthias.bgg,
	angelogioacchino.delregno, brgl
  Cc: linux-mediatek, linux-gpio, linux-kernel, linux-arm-kernel,
	bartosz.golaszewski

> Gesendet: Freitag, 10. April 2026 um 09:09
> Von: "Bartosz Golaszewski" <bartosz.golaszewski@oss.qualcomm.com>
> An: "Frank Wunderlich" <linux@fw-web.de>, "Sean Wang" <sean.wang@kernel.org>, "Linus Walleij" <linusw@kernel.org>, "Matthias Brugger" <matthias.bgg@gmail.com>, "AngeloGioacchino Del Regno" <angelogioacchino.delregno@collabora.com>, "Bartosz Golaszewski" <brgl@kernel.org>
> CC: linux-mediatek@lists.infradead.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, "Bartosz Golaszewski" <bartosz.golaszewski@oss.qualcomm.com>
> 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()")
> Reported-by: Frank Wunderlich <linux@fw-web.de>

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

> Closes: https://lore.kernel.org/all/20260409132724.126258-1-linux@fw-web.de/
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] pinctrl: mediatek: moore: implement gpio_chip::get_direction()
  2026-04-10  9:24 ` Aw: " Frank Wunderlich
@ 2026-04-10  9:54   ` Bartosz Golaszewski
  2026-04-10 11:23     ` Aw: " Frank Wunderlich
  0 siblings, 1 reply; 5+ messages in thread
From: Bartosz Golaszewski @ 2026-04-10  9:54 UTC (permalink / raw)
  To: Frank Wunderlich
  Cc: bartosz.golaszewski, linux, sean.wang, linusw, matthias.bgg,
	angelogioacchino.delregno, linux-mediatek, linux-gpio,
	linux-kernel, linux-arm-kernel

On Fri, Apr 10, 2026 at 11:24 AM Frank Wunderlich
<frank-w@public-files.de> wrote:
>
> > Gesendet: Freitag, 10. April 2026 um 09:09
> > Von: "Bartosz Golaszewski" <bartosz.golaszewski@oss.qualcomm.com>
> > An: "Frank Wunderlich" <linux@fw-web.de>, "Sean Wang" <sean.wang@kernel.org>, "Linus Walleij" <linusw@kernel.org>, "Matthias Brugger" <matthias.bgg@gmail.com>, "AngeloGioacchino Del Regno" <angelogioacchino.delregno@collabora.com>, "Bartosz Golaszewski" <brgl@kernel.org>
> > CC: linux-mediatek@lists.infradead.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, "Bartosz Golaszewski" <bartosz.golaszewski@oss.qualcomm.com>
> > 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()")
> > Reported-by: Frank Wunderlich <linux@fw-web.de>
>
> 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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Aw: Re: [PATCH] pinctrl: mediatek: moore: implement gpio_chip::get_direction()
  2026-04-10  9:54   ` Bartosz Golaszewski
@ 2026-04-10 11:23     ` Frank Wunderlich
  0 siblings, 0 replies; 5+ messages in thread
From: Frank Wunderlich @ 2026-04-10 11:23 UTC (permalink / raw)
  To: brgl
  Cc: bartosz.golaszewski, linux, sean.wang, linusw, matthias.bgg,
	angelogioacchino.delregno, linux-mediatek, linux-gpio,
	linux-kernel, linux-arm-kernel


> > > Reported-by: Frank Wunderlich <linux@fw-web.de>
> >
> > 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)

Tested-By: Frank Wunderlich <frank-w@public-files.de>

> Thanks,
> Bartosz


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-04-10 11:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-10  7:09 [PATCH] pinctrl: mediatek: moore: implement gpio_chip::get_direction() Bartosz Golaszewski
2026-04-10  7:37 ` Linus Walleij
2026-04-10  9:24 ` Aw: " Frank Wunderlich
2026-04-10  9:54   ` Bartosz Golaszewski
2026-04-10 11:23     ` Aw: " Frank Wunderlich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox