diff mbox series

gpiolib: acpi: Fix GPIO lookup using relative path

Message ID 20261001152343.1995157-1-alban.bedel@lht.dlh.de
State New
Headers show
Series gpiolib: acpi: Fix GPIO lookup using relative path | expand

Commit Message

Alban Bedel Oct. 1, 2026, 3:23 p.m. UTC
ACPI allow to use relative path in resources, pass the device handle
to acpi_get_gpiod() to allow resolving such path.

Signed-off-by: Alban Bedel <alban.bedel@lht.dlh.de>
---
 drivers/gpio/gpiolib-acpi-core.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Comments

Mika Westerberg Oct. 2, 2026, 4:36 a.m. UTC | #1
On Thu, Oct 01, 2026 at 05:23:43PM +0200, Alban Bedel wrote:
> ACPI allow to use relative path in resources, pass the device handle
> to acpi_get_gpiod() to allow resolving such path.
> 
> Signed-off-by: Alban Bedel <alban.bedel@lht.dlh.de>

Acked-by: Mika Westerberg <westeri@kernel.org>
Andy Shevchenko Oct. 2, 2026, 7:09 a.m. UTC | #2
On Fri, Oct 02, 2026 at 06:36:08AM +0200, Mika Westerberg wrote:
> On Thu, Oct 01, 2026 at 05:23:43PM +0200, Alban Bedel wrote:
> > ACPI allow to use relative path in resources, pass the device handle
> > to acpi_get_gpiod() to allow resolving such path.
> > 
> > Signed-off-by: Alban Bedel <alban.bedel@lht.dlh.de>
> 
> Acked-by: Mika Westerberg <westeri@kernel.org>

Interestingly that I have no original patch in my mailbox.
Whatever, Alban, do you have IRL case, or is it for the to be
productised platform?
diff mbox series

Patch

diff --git a/drivers/gpio/gpiolib-acpi-core.c b/drivers/gpio/gpiolib-acpi-core.c
index 220f0ac4204ef..16f0196ad0742 100644
--- a/drivers/gpio/gpiolib-acpi-core.c
+++ b/drivers/gpio/gpiolib-acpi-core.c
@@ -116,7 +116,8 @@  static int acpi_gpiochip_find(struct gpio_chip *gc, const void *data)
 
 /**
  * acpi_get_gpiod() - Translate ACPI GPIO pin to GPIO descriptor usable with GPIO API
- * @path:	ACPI GPIO controller full path name, (e.g. "\\_SB.GPO1")
+ * @parent:	parent ACPI handle to resolve relative path
+ * @path:	ACPI GPIO controller path name, (e.g. "\\_SB.GPO1" or "^GP01")
  * @pin:	ACPI GPIO pin number (0-based, controller-relative)
  *
  * Returns:
@@ -128,12 +129,13 @@  static int acpi_gpiochip_find(struct gpio_chip *gc, const void *data)
  * controller does not have GPIO chip registered at the moment. This is to
  * support probe deferral.
  */
-static struct gpio_desc *acpi_get_gpiod(char *path, unsigned int pin)
+static struct gpio_desc *acpi_get_gpiod(acpi_handle parent,
+					char *path, unsigned int pin)
 {
 	acpi_handle handle;
 	acpi_status status;
 
-	status = acpi_get_handle(NULL, path, &handle);
+	status = acpi_get_handle(parent, path, &handle);
 	if (ACPI_FAILURE(status))
 		return ERR_PTR(-ENODEV);
 
@@ -733,7 +735,8 @@  static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *data)
 		if (info->quirks & ACPI_GPIO_QUIRK_ABSOLUTE_NUMBER)
 			desc = gpio_to_desc(agpio->pin_table[pin_index]);
 		else
-			desc = acpi_get_gpiod(agpio->resource_source.string_ptr,
+			desc = acpi_get_gpiod(acpi_device_handle(info->adev),
+					      agpio->resource_source.string_ptr,
 					      agpio->pin_table[pin_index]);
 		lookup->desc = desc;
 		info->pin_config = agpio->pin_config;