2023-05-06 09:08:42

by Bough Chen

[permalink] [raw]
Subject: [PATCH 2/2] gpio: mxc: switch to dynamic allocat GPIO base

From: Haibo Chen <[email protected]>

gpiolib want to get completely rid of static gpiobase allocation,
so switch to dynamic allocat GPIO base, also can avoid warning
message:

[ 1.529974] gpio gpiochip0: Static allocation of GPIO base
is deprecated, use dynamic allocation.

Signed-off-by: Haibo Chen <[email protected]>
---
drivers/gpio/gpio-mxc.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c
index 9d0cec4b82a3..abc129a88a62 100644
--- a/drivers/gpio/gpio-mxc.c
+++ b/drivers/gpio/gpio-mxc.c
@@ -462,8 +462,7 @@ static int mxc_gpio_probe(struct platform_device *pdev)
port->gc.request = gpiochip_generic_request;
port->gc.free = gpiochip_generic_free;
port->gc.to_irq = mxc_gpio_to_irq;
- port->gc.base = (pdev->id < 0) ? of_alias_get_id(np, "gpio") * 32 :
- pdev->id * 32;
+ port->gc.base = -1;

err = devm_gpiochip_add_data(&pdev->dev, &port->gc, port);
if (err)
--
2.34.1


2023-05-06 13:08:37

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH 2/2] gpio: mxc: switch to dynamic allocat GPIO base

On Sat, May 6, 2023 at 10:56 AM <[email protected]> wrote:

> From: Haibo Chen <[email protected]>
>
> gpiolib want to get completely rid of static gpiobase allocation,
> so switch to dynamic allocat GPIO base, also can avoid warning
> message:
>
> [ 1.529974] gpio gpiochip0: Static allocation of GPIO base
> is deprecated, use dynamic allocation.
>
> Signed-off-by: Haibo Chen <[email protected]>

Reviewed-by: Linus Walleij <[email protected]>

Yours,
Linus Walleij

2023-05-26 13:29:04

by Bartosz Golaszewski

[permalink] [raw]
Subject: Re: [PATCH 2/2] gpio: mxc: switch to dynamic allocat GPIO base

On Sat, May 6, 2023 at 10:56 AM <[email protected]> wrote:
>
> From: Haibo Chen <[email protected]>
>
> gpiolib want to get completely rid of static gpiobase allocation,
> so switch to dynamic allocat GPIO base, also can avoid warning
> message:
>
> [ 1.529974] gpio gpiochip0: Static allocation of GPIO base
> is deprecated, use dynamic allocation.
>
> Signed-off-by: Haibo Chen <[email protected]>
> ---
> drivers/gpio/gpio-mxc.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c
> index 9d0cec4b82a3..abc129a88a62 100644
> --- a/drivers/gpio/gpio-mxc.c
> +++ b/drivers/gpio/gpio-mxc.c
> @@ -462,8 +462,7 @@ static int mxc_gpio_probe(struct platform_device *pdev)
> port->gc.request = gpiochip_generic_request;
> port->gc.free = gpiochip_generic_free;
> port->gc.to_irq = mxc_gpio_to_irq;
> - port->gc.base = (pdev->id < 0) ? of_alias_get_id(np, "gpio") * 32 :
> - pdev->id * 32;
> + port->gc.base = -1;
>
> err = devm_gpiochip_add_data(&pdev->dev, &port->gc, port);
> if (err)
> --
> 2.34.1
>

This is not the first time we're seeing someone submit this fix[1].

Unfortunately it's been brought to our attention that this breaks
existing user-space scripts that rely on fixed GPIO numbering in
sysfs.

Bart

[1] https://lore.kernel.org/lkml/CACRpkdYV3mHNYvBg1nf+12Q2XZH_g4iTrA2YB1SVQ=ROriRRgg@mail.gmail.com/T/