* commit f34fd6ee1be8 breaks current dwapb gpio DT users
@ 2024-02-17 14:15 Jisheng Zhang
2024-02-17 17:44 ` Emil Renner Berthing
0 siblings, 1 reply; 5+ messages in thread
From: Jisheng Zhang @ 2024-02-17 14:15 UTC (permalink / raw)
To: Emil Renner Berthing, Linus Walleij; +Cc: linux-gpio, devicetree
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?
Thanks in advance
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: commit f34fd6ee1be8 breaks current dwapb gpio DT users
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
2024-02-19 13:46 ` Linus Walleij
0 siblings, 2 replies; 5+ messages in thread
From: Emil Renner Berthing @ 2024-02-17 17:44 UTC (permalink / raw)
To: Jisheng Zhang, Emil Renner Berthing, Linus Walleij; +Cc: linux-gpio, devicetree
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);
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: commit f34fd6ee1be8 breaks current dwapb gpio DT users
2024-02-17 17:44 ` Emil Renner Berthing
@ 2024-02-18 2:20 ` Jisheng Zhang
2024-02-19 13:46 ` Linus Walleij
1 sibling, 0 replies; 5+ messages in thread
From: Jisheng Zhang @ 2024-02-18 2:20 UTC (permalink / raw)
To: Emil Renner Berthing; +Cc: Linus Walleij, linux-gpio, devicetree
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: commit f34fd6ee1be8 breaks current dwapb gpio DT users
2024-02-17 17:44 ` Emil Renner Berthing
2024-02-18 2:20 ` Jisheng Zhang
@ 2024-02-19 13:46 ` Linus Walleij
2024-02-19 15:27 ` Emil Renner Berthing
1 sibling, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2024-02-19 13:46 UTC (permalink / raw)
To: Emil Renner Berthing; +Cc: Jisheng Zhang, linux-gpio, devicetree
On Sat, Feb 17, 2024 at 6:44 PM Emil Renner Berthing
<emil.renner.berthing@canonical.com> wrote:
> --- 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
Please do this:
if (IS_ENABLED(CONFIG_PINCTRL) && list_empty(&gc->gpiodev->pin_ranges))
...
The ifdef is so ugly.
> + if (list_empty(&gc->gpiodev->pin_ranges))
> + return -ENOTSUPP;
> +#endif
That looks like a reasonable fix, I try to wrap my head around if it
would affect
any users but can't figure it out, we have to test.
Can you please send it as a proper patch? With the above fixed:
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: commit f34fd6ee1be8 breaks current dwapb gpio DT users
2024-02-19 13:46 ` Linus Walleij
@ 2024-02-19 15:27 ` Emil Renner Berthing
0 siblings, 0 replies; 5+ messages in thread
From: Emil Renner Berthing @ 2024-02-19 15:27 UTC (permalink / raw)
To: Linus Walleij, Emil Renner Berthing; +Cc: Jisheng Zhang, linux-gpio, devicetree
Linus Walleij wrote:
> On Sat, Feb 17, 2024 at 6:44 PM Emil Renner Berthing
> <emil.renner.berthing@canonical.com> wrote:
>
> > --- 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
>
> Please do this:
>
> if (IS_ENABLED(CONFIG_PINCTRL) && list_empty(&gc->gpiodev->pin_ranges))
> ...
>
> The ifdef is so ugly.
I agree, but I'm not sure it will work in this case since the pin_ranges
member is only there when CONFIG_PINCTRL=y. That would also explain why
gpiochip_generic_request() and gpiochip_generic_free() use ifdefs.
>
> > + if (list_empty(&gc->gpiodev->pin_ranges))
> > + return -ENOTSUPP;
> > +#endif
>
> That looks like a reasonable fix, I try to wrap my head around if it
> would affect
> any users but can't figure it out, we have to test.
>
> Can you please send it as a proper patch? With the above fixed:
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Will do, thanks!
/Emil
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-02-19 15:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2024-02-19 13:46 ` Linus Walleij
2024-02-19 15:27 ` Emil Renner Berthing
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).