devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jisheng Zhang <jszhang@kernel.org>
To: Emil Renner Berthing <emil.renner.berthing@canonical.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	linux-gpio@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: commit f34fd6ee1be8 breaks current dwapb gpio DT users
Date: Sun, 18 Feb 2024 10:20:46 +0800	[thread overview]
Message-ID: <ZdFpfrZjN7UvUFrr@xhacker> (raw)
In-Reply-To: <CAJM55Z-t9e8L2_iFfdbCDpOzi7UxQao6-L6VU_W9OGBciJ46bA@mail.gmail.com>

On Sat, Feb 17, 2024 at 09:44:27AM -0800, Emil Renner Berthing wrote:
> Jisheng Zhang wrote:
> > Hi Emil, Linus,
> >
> > commit f34fd6ee1be8 ("gpio: dwapb: Use generic request, free and
> > set_config") breaks all current dwapb gpio DT users, for example, getting
> > cd-gpios will always fail as -EPROBE_DEFER. Before the commit,
> > dwapb_gpio_set_config() returns -ENOTSUPP for !PIN_CONFIG_INPUT_DEBOUNCE
> > then gpio_set_config_with_argument_optional() will happily ignore
> > -ENOTSUPP. After the commit, dwapb_gpio_set_config() will return
> > -EPROBE_DEFER unless the gpio-ranges are set in DT.
> >
> > The key problem here is: almost all dwapb gpio DT users don't set
> > the gpio-ranges DT property, so I guess current dwapb gpio DT users
> > have this problem and the commit also breaks old DT compatbility.
> > So could we getback to previous behavior?
> 
> Hi Jisheng
> 
> It seems like the gpiochip_generic_request() and gpiochip_generic_free()
> functions have guards to handle when gpio-ranges are not set that
> gpiochip_generic_config() lacks. Could you try the patch below?
> 
> Otherwise I'm also fine with just reverting the patch if this is not the right
> solution.
> 
> /Emil
> 
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index 8b3a0f45b574..e434e8cc1229 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -2042,6 +2042,11 @@ EXPORT_SYMBOL_GPL(gpiochip_generic_free);
>  int gpiochip_generic_config(struct gpio_chip *gc, unsigned int offset,
>                             unsigned long config)
>  {
> +#ifdef CONFIG_PINCTRL
> +       if (list_empty(&gc->gpiodev->pin_ranges))
> +               return -ENOTSUPP;
> +#endif
> +
>         return pinctrl_gpio_set_config(gc, offset, config);
>  }
>  EXPORT_SYMBOL_GPL(gpiochip_generic_config);

Hi Emil,

The above patch can fix the gpio issue. So,
Reported-by: Jisheng Zhang <jszhang@kernel.org>
Tested-by: Jisheng Zhang <jszhang@kernel.org>

Thanks

  reply	other threads:[~2024-02-18  2:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-17 14:15 commit f34fd6ee1be8 breaks current dwapb gpio DT users Jisheng Zhang
2024-02-17 17:44 ` Emil Renner Berthing
2024-02-18  2:20   ` Jisheng Zhang [this message]
2024-02-19 13:46   ` Linus Walleij
2024-02-19 15:27     ` Emil Renner Berthing

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=ZdFpfrZjN7UvUFrr@xhacker \
    --to=jszhang@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=emil.renner.berthing@canonical.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    /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 NNTP newsgroup(s).