Linux-GPIO Archive mirror
 help / color / mirror / Atom feed
From: Frank Wunderlich <frank-w@public-files.de>
To: brgl@kernel.org, linux@fw-web.de
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	daniel@makrotopia.org, linusw@kernel.org, brgl@kernel.org
Subject: Aw: Re: [PATCH v1] gpiolib: fix trace on missing gpiochip->get_direction callback
Date: Thu, 9 Apr 2026 20:42:10 +0000	[thread overview]
Message-ID: <trinity-93899756-f769-4496-9acf-268f65f0d612-1775767330691@trinity-msg-rest-gmx-gmx-live-5cf7d7879b-89lbz> (raw)
In-Reply-To: <CAMRc=Mdh=P8ABX2kO-j9hp0oy=1-9rJZUYwZR4APNz1qK9FVcQ@mail.gmail.com>

Hi

> Gesendet: Donnerstag, 9. April 2026 um 16:23
> Von: "Bartosz Golaszewski" <brgl@kernel.org>
> 
> I prefer GPIO drivers to just implement get_direction(). Looking at the code
> it should be pretty straightforward for this driver.
> 
> Can you test if the following works for you?
> 
> 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 *)&amp;hw->soc->pins[offset];
> +	if (!desc->name)
> +		return -ENOTSUPP;
> +
> +	ret = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DIR, &amp;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;

it looks good on a quick test, just reverted my patch and applied yours and got no trace 

root@bpi-r4:~# cat /sys/kernel/debug/gpio 
gpiochip0: 84 GPIOs, parent: platform/1001f000.pinctrl, pinctrl_moore:
 gpio-0   (                    |tx-disable          ) in  lo 
 gpio-1   (                    |mod-def0            ) in  hi IRQ ACTIVE LOW
 gpio-2   (                    |los                 ) in  hi IRQ 
 gpio-12  (                    |cd                  ) in  lo IRQ ACTIVE LOW
 gpio-13  (                    |reset               ) in  hi IRQ ACTIVE LOW
 gpio-14  (                    |WPS                 ) in  hi IRQ ACTIVE LOW
 gpio-21  (                    |tx-disable          ) out hi 
 gpio-69  (                    |mod-def0            ) in  lo IRQ ACTIVE LOW
 gpio-70  (                    |los                 ) in  hi IRQ 

gpiochip1: 16 GPIOs, parent: i2c/3-0020, 3-0020, can sleep:
 gpio-14  (                    |blue:activity       ) out lo 
 gpio-15  (                    |red:fault           ) out lo 

output seems correct.

regards Frank

> Thanks,
> Bart

      reply	other threads:[~2026-04-09 20:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-09 13:27 [PATCH v1] gpiolib: fix trace on missing gpiochip->get_direction callback Frank Wunderlich
2026-04-09 14:23 ` Bartosz Golaszewski
2026-04-09 20:42   ` Frank Wunderlich [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=trinity-93899756-f769-4496-9acf-268f65f0d612-1775767330691@trinity-msg-rest-gmx-gmx-live-5cf7d7879b-89lbz \
    --to=frank-w@public-files.de \
    --cc=brgl@kernel.org \
    --cc=daniel@makrotopia.org \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@fw-web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).