All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] gpiolib: Avoid modifying GPIO chip fwnode
@ 2023-07-03 14:23 Andy Shevchenko
  2023-07-03 14:23 ` [PATCH v2 1/3] gpiolib: of: Don't use GPIO chip fwnode in of_gpiochip_*() Andy Shevchenko
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Andy Shevchenko @ 2023-07-03 14:23 UTC (permalink / raw)
  To: Andy Shevchenko, Dmitry Torokhov, Bartosz Golaszewski,
	linux-gpio, linux-acpi, linux-kernel
  Cc: Mika Westerberg, Linus Walleij, Bartosz Golaszewski

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 1/3] gpiolib: of: Don't use GPIO chip fwnode in of_gpiochip_*()
  2023-07-03 14:23 [PATCH v2 0/3] gpiolib: Avoid modifying GPIO chip fwnode Andy Shevchenko
@ 2023-07-03 14:23 ` Andy Shevchenko
  2023-07-03 14:23 ` [PATCH v2 2/3] gpiolib: acpi: Don't use GPIO chip fwnode in acpi_gpiochip_find() Andy Shevchenko
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2023-07-03 14:23 UTC (permalink / raw)
  To: Andy Shevchenko, Dmitry Torokhov, Bartosz Golaszewski,
	linux-gpio, linux-acpi, linux-kernel
  Cc: Mika Westerberg, Linus Walleij, Bartosz Golaszewski, Benjamin Tissoires

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 <andriy.shevchenko@linux.intel.com>
Tested-by: Benjamin Tissoires <bentiss@kernel.org>
---
 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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 2/3] gpiolib: acpi: Don't use GPIO chip fwnode in acpi_gpiochip_find()
  2023-07-03 14:23 [PATCH v2 0/3] gpiolib: Avoid modifying GPIO chip fwnode Andy Shevchenko
  2023-07-03 14:23 ` [PATCH v2 1/3] gpiolib: of: Don't use GPIO chip fwnode in of_gpiochip_*() Andy Shevchenko
@ 2023-07-03 14:23 ` Andy Shevchenko
  2023-07-03 14:43   ` Benjamin Tissoires
  2023-07-03 14:23 ` [PATCH v2 3/3] gpiolib: Do not alter GPIO chip fwnode member Andy Shevchenko
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: Andy Shevchenko @ 2023-07-03 14:23 UTC (permalink / raw)
  To: Andy Shevchenko, Dmitry Torokhov, Bartosz Golaszewski,
	linux-gpio, linux-acpi, linux-kernel
  Cc: Mika Westerberg, Linus Walleij, Bartosz Golaszewski, Benjamin Tissoires

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 <andriy.shevchenko@linux.intel.com>
Tested-by: Benjamin Tissoires <bentiss@kernel.org>
---
 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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 3/3] gpiolib: Do not alter GPIO chip fwnode member
  2023-07-03 14:23 [PATCH v2 0/3] gpiolib: Avoid modifying GPIO chip fwnode Andy Shevchenko
  2023-07-03 14:23 ` [PATCH v2 1/3] gpiolib: of: Don't use GPIO chip fwnode in of_gpiochip_*() Andy Shevchenko
  2023-07-03 14:23 ` [PATCH v2 2/3] gpiolib: acpi: Don't use GPIO chip fwnode in acpi_gpiochip_find() Andy Shevchenko
@ 2023-07-03 14:23 ` Andy Shevchenko
  2023-07-04  9:11 ` [PATCH v2 0/3] gpiolib: Avoid modifying GPIO chip fwnode Linus Walleij
  2023-07-10  9:26 ` Bartosz Golaszewski
  4 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2023-07-03 14:23 UTC (permalink / raw)
  To: Andy Shevchenko, Dmitry Torokhov, Bartosz Golaszewski,
	linux-gpio, linux-acpi, linux-kernel
  Cc: Mika Westerberg, Linus Walleij, Bartosz Golaszewski, Benjamin Tissoires

Ideally we should not touch data in the given GPIO chip structure.
Let's become closer to it by avoiding altering fwnode member.

The GPIO library must use fwnode from GPIO device and the drivers
might use one from GPIO chip in case they initialized it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Benjamin Tissoires <bentiss@kernel.org>
---
 drivers/gpio/gpiolib.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index bc8b9d6afe0e..8b7032300039 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -708,13 +708,6 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
 	int base = 0;
 	int ret = 0;
 
-	/*
-	 * If the calling driver did not initialize firmware node, do it here
-	 * using the parent device, if any.
-	 */
-	if (!gc->fwnode && gc->parent)
-		gc->fwnode = dev_fwnode(gc->parent);
-
 	/*
 	 * First: allocate and populate the internal stat container, and
 	 * set up the struct device.
@@ -729,7 +722,14 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
 	gc->gpiodev = gdev;
 	gpiochip_set_data(gc, data);
 
-	device_set_node(&gdev->dev, gc->fwnode);
+	/*
+	 * If the calling driver did not initialize firmware node,
+	 * do it here using the parent device, if any.
+	 */
+	if (gc->fwnode)
+		device_set_node(&gdev->dev, gc->fwnode);
+	else if (gc->parent)
+		device_set_node(&gdev->dev, dev_fwnode(gc->parent));
 
 	gdev->id = ida_alloc(&gpio_ida, GFP_KERNEL);
 	if (gdev->id < 0) {
-- 
2.40.0.1.gaa8946217a0b


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 2/3] gpiolib: acpi: Don't use GPIO chip fwnode in acpi_gpiochip_find()
  2023-07-03 14:23 ` [PATCH v2 2/3] gpiolib: acpi: Don't use GPIO chip fwnode in acpi_gpiochip_find() Andy Shevchenko
@ 2023-07-03 14:43   ` Benjamin Tissoires
  2023-07-03 14:56     ` Andy Shevchenko
  0 siblings, 1 reply; 8+ messages in thread
From: Benjamin Tissoires @ 2023-07-03 14:43 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Dmitry Torokhov, Bartosz Golaszewski, linux-gpio, linux-acpi,
	linux-kernel, Mika Westerberg, Linus Walleij,
	Bartosz Golaszewski, Benjamin Tissoires

On Mon, Jul 3, 2023 at 4:29 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> 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 <andriy.shevchenko@linux.intel.com>
> Tested-by: Benjamin Tissoires <bentiss@kernel.org>
> ---
>  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
>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 2/3] gpiolib: acpi: Don't use GPIO chip fwnode in acpi_gpiochip_find()
  2023-07-03 14:43   ` Benjamin Tissoires
@ 2023-07-03 14:56     ` Andy Shevchenko
  0 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2023-07-03 14:56 UTC (permalink / raw)
  To: Benjamin Tissoires
  Cc: Dmitry Torokhov, Bartosz Golaszewski, linux-gpio, linux-acpi,
	linux-kernel, Mika Westerberg, Linus Walleij,
	Bartosz Golaszewski, Benjamin Tissoires

On Mon, Jul 03, 2023 at 04:43:05PM +0200, Benjamin Tissoires wrote:
> On Mon, Jul 3, 2023 at 4:29 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> 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



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 0/3] gpiolib: Avoid modifying GPIO chip fwnode
  2023-07-03 14:23 [PATCH v2 0/3] gpiolib: Avoid modifying GPIO chip fwnode Andy Shevchenko
                   ` (2 preceding siblings ...)
  2023-07-03 14:23 ` [PATCH v2 3/3] gpiolib: Do not alter GPIO chip fwnode member Andy Shevchenko
@ 2023-07-04  9:11 ` Linus Walleij
  2023-07-10  9:26 ` Bartosz Golaszewski
  4 siblings, 0 replies; 8+ messages in thread
From: Linus Walleij @ 2023-07-04  9:11 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Dmitry Torokhov, Bartosz Golaszewski, linux-gpio, linux-acpi,
	linux-kernel, Mika Westerberg, Bartosz Golaszewski

On Mon, Jul 3, 2023 at 4:23 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> 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 <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 0/3] gpiolib: Avoid modifying GPIO chip fwnode
  2023-07-03 14:23 [PATCH v2 0/3] gpiolib: Avoid modifying GPIO chip fwnode Andy Shevchenko
                   ` (3 preceding siblings ...)
  2023-07-04  9:11 ` [PATCH v2 0/3] gpiolib: Avoid modifying GPIO chip fwnode Linus Walleij
@ 2023-07-10  9:26 ` Bartosz Golaszewski
  4 siblings, 0 replies; 8+ messages in thread
From: Bartosz Golaszewski @ 2023-07-10  9:26 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Dmitry Torokhov, Bartosz Golaszewski, linux-gpio, linux-acpi,
	linux-kernel, Mika Westerberg, Linus Walleij

On Mon, Jul 3, 2023 at 4:23 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-07-10  9:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-03 14:23 [PATCH v2 0/3] gpiolib: Avoid modifying GPIO chip fwnode Andy Shevchenko
2023-07-03 14:23 ` [PATCH v2 1/3] gpiolib: of: Don't use GPIO chip fwnode in of_gpiochip_*() Andy Shevchenko
2023-07-03 14:23 ` [PATCH v2 2/3] gpiolib: acpi: Don't use GPIO chip fwnode in acpi_gpiochip_find() Andy Shevchenko
2023-07-03 14:43   ` Benjamin Tissoires
2023-07-03 14:56     ` Andy Shevchenko
2023-07-03 14:23 ` [PATCH v2 3/3] gpiolib: Do not alter GPIO chip fwnode member Andy Shevchenko
2023-07-04  9:11 ` [PATCH v2 0/3] gpiolib: Avoid modifying GPIO chip fwnode Linus Walleij
2023-07-10  9:26 ` Bartosz Golaszewski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.