2023-07-03 14:43:13

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v2 0/3] gpiolib: Avoid modifying GPIO chip fwnode

Ideally the GPIO chip data structure has to be constant.
In real life it's not true, but we can make it closer to
that. Hence the series.

Bart, the idea is that this series has to land immediately after
v6.5-rc1 is out so we will have longer time to fix downsides and
regressions found, if any.

Benjamin, thank you for testing!

Changelog v2:
- replaced open coded device_match_acpi_handle()
- corrected commit message due to above change
- added tag (Benjamin)

Andy Shevchenko (3):
gpiolib: of: Don't use GPIO chip fwnode in of_gpiochip_*()
gpiolib: acpi: Don't use GPIO chip fwnode in acpi_gpiochip_find()
gpiolib: Do not alter GPIO chip fwnode member

drivers/gpio/gpiolib-acpi.c | 2 +-
drivers/gpio/gpiolib-of.c | 6 +++---
drivers/gpio/gpiolib.c | 16 ++++++++--------
3 files changed, 12 insertions(+), 12 deletions(-)

--
2.40.0.1.gaa8946217a0b



2023-07-03 14:43:36

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v2 2/3] gpiolib: acpi: Don't use GPIO chip fwnode in acpi_gpiochip_find()

GPIO library should rely only on the GPIO device's fwnode.
Hence, replace GPIO chip fwnode usage by respective handle
of the GPIO device.

Signed-off-by: Andy Shevchenko <[email protected]>
Tested-by: Benjamin Tissoires <[email protected]>
---
drivers/gpio/gpiolib-acpi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index 97496c0f9133..fbda452fb4d6 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -128,7 +128,7 @@ static bool acpi_gpio_deferred_req_irqs_done;

static int acpi_gpiochip_find(struct gpio_chip *gc, void *data)
{
- return ACPI_HANDLE_FWNODE(gc->fwnode) == data;
+ return device_match_acpi_handle(&gc->gpiodev->dev, data);
}

/**
--
2.40.0.1.gaa8946217a0b


2023-07-03 14:43:49

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v2 1/3] gpiolib: of: Don't use GPIO chip fwnode in of_gpiochip_*()

GPIO library should rely only on the GPIO device's fwnode.
Hence, replace GPIO chip fwnode usage by respective OF node
of the GPIO device.

JFYI, this is partial revert of 8afe82550240 ("gpiolib: of:
Prepare of_gpiochip_add() / of_gpiochip_remove() for fwnode").

Signed-off-by: Andy Shevchenko <[email protected]>
Tested-by: Benjamin Tissoires <[email protected]>
---
drivers/gpio/gpiolib-of.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index 1436cdb5fa26..5fde5a3f5118 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -1078,16 +1078,16 @@ int of_gpiochip_add(struct gpio_chip *chip)
if (ret)
return ret;

- fwnode_handle_get(chip->fwnode);
+ of_node_get(np);

ret = of_gpiochip_scan_gpios(chip);
if (ret)
- fwnode_handle_put(chip->fwnode);
+ of_node_put(np);

return ret;
}

void of_gpiochip_remove(struct gpio_chip *chip)
{
- fwnode_handle_put(chip->fwnode);
+ of_node_put(dev_of_node(&chip->gpiodev->dev));
}
--
2.40.0.1.gaa8946217a0b


2023-07-03 14:51:09

by Benjamin Tissoires

[permalink] [raw]
Subject: Re: [PATCH v2 2/3] gpiolib: acpi: Don't use GPIO chip fwnode in acpi_gpiochip_find()

On Mon, Jul 3, 2023 at 4:29 PM Andy Shevchenko
<[email protected]> wrote:
>
> GPIO library should rely only on the GPIO device's fwnode.
> Hence, replace GPIO chip fwnode usage by respective handle
> of the GPIO device.
>
> Signed-off-by: Andy Shevchenko <[email protected]>
> Tested-by: Benjamin Tissoires <[email protected]>
> ---
> drivers/gpio/gpiolib-acpi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
> index 97496c0f9133..fbda452fb4d6 100644
> --- a/drivers/gpio/gpiolib-acpi.c
> +++ b/drivers/gpio/gpiolib-acpi.c
> @@ -128,7 +128,7 @@ static bool acpi_gpio_deferred_req_irqs_done;
>
> static int acpi_gpiochip_find(struct gpio_chip *gc, void *data)
> {
> - return ACPI_HANDLE_FWNODE(gc->fwnode) == data;
> + return device_match_acpi_handle(&gc->gpiodev->dev, data);

Quick confirmation that using "device_match_acpi_handle" also works in
v2 (was easy enough to test given that everything was already set up
locally).

Cheers,
Benjamin

> }
>
> /**
> --
> 2.40.0.1.gaa8946217a0b
>


2023-07-03 15:24:55

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v2 2/3] gpiolib: acpi: Don't use GPIO chip fwnode in acpi_gpiochip_find()

On Mon, Jul 03, 2023 at 04:43:05PM +0200, Benjamin Tissoires wrote:
> On Mon, Jul 3, 2023 at 4:29 PM Andy Shevchenko
> <[email protected]> wrote:

> > - return ACPI_HANDLE_FWNODE(gc->fwnode) == data;
> > + return device_match_acpi_handle(&gc->gpiodev->dev, data);
>
> Quick confirmation that using "device_match_acpi_handle" also works in
> v2 (was easy enough to test given that everything was already set up
> locally).

Thank you! I would be very surprised if not :-)

--
With Best Regards,
Andy Shevchenko



2023-07-04 09:20:39

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH v2 0/3] gpiolib: Avoid modifying GPIO chip fwnode

On Mon, Jul 3, 2023 at 4:23 PM Andy Shevchenko
<[email protected]> wrote:

> Ideally the GPIO chip data structure has to be constant.
> In real life it's not true, but we can make it closer to
> that. Hence the series.

The series looks completely reasonable to me:
Reviewed-by: Linus Walleij <[email protected]>

Yours,
Linus Walleij

2023-07-10 09:30:16

by Bartosz Golaszewski

[permalink] [raw]
Subject: Re: [PATCH v2 0/3] gpiolib: Avoid modifying GPIO chip fwnode

On Mon, Jul 3, 2023 at 4:23 PM Andy Shevchenko
<[email protected]> wrote:
>
> Ideally the GPIO chip data structure has to be constant.
> In real life it's not true, but we can make it closer to
> that. Hence the series.
>
> Bart, the idea is that this series has to land immediately after
> v6.5-rc1 is out so we will have longer time to fix downsides and
> regressions found, if any.
>
> Benjamin, thank you for testing!
>
> Changelog v2:
> - replaced open coded device_match_acpi_handle()
> - corrected commit message due to above change
> - added tag (Benjamin)
>
> Andy Shevchenko (3):
> gpiolib: of: Don't use GPIO chip fwnode in of_gpiochip_*()
> gpiolib: acpi: Don't use GPIO chip fwnode in acpi_gpiochip_find()
> gpiolib: Do not alter GPIO chip fwnode member
>
> drivers/gpio/gpiolib-acpi.c | 2 +-
> drivers/gpio/gpiolib-of.c | 6 +++---
> drivers/gpio/gpiolib.c | 16 ++++++++--------
> 3 files changed, 12 insertions(+), 12 deletions(-)
>
> --
> 2.40.0.1.gaa8946217a0b
>

Applied, thanks!

Bart