Commit 9949926a authored by Devyn Liu's avatar Devyn Liu Committed by hongrongxuan
Browse files

gpiolib: acpi: Fix failed in acpi_gpiochip_find() by adding parent node match

driver inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I9QV07


CVE: NA

------------------------------------------------------------------

Previous patch modified the standard used by acpi_gpiochip_find()
to match device nodes. Using the device node set in gc->gpiodev->d-
ev instead of gc->parent.

However, there is a situation in gpio-dwapb where the GPIO device
driver will set gc->fwnode for each port corresponding to a child
node under a GPIO device, so gc->gpiodev->dev will be assigned the
value of each child node in gpiochip_add_data().

When other drivers request GPIO pin resources through the GPIO device
node provided by ACPI (corresponding to the parent node), the change
of the matching object to gc->gpiodev->dev in acpi_gpiochip_find()
only allows finding the value of each port (child node), resulting
in a failed request.

Reapply the condition of using gc->parent for match in acpi_gpio-
chip_find() in the code can compatible with the problem of gpio-dwapb,
and will not affect the two cases mentioned in the patch:
1. There is no setting for gc->fwnode.
2. The case that depends on using gc->fwnode for match.

Fixes: 5062e4c1 ("gpiolib: acpi: use the fwnode in acpi_gpiochip_find()")
Signed-off-by: default avatarDevyn Liu <liudingyuan@huawei.com>
Signed-off-by: default avatarJunhua Lu <lujunhua7@h-partners.com>
Signed-off-by: default avatarhongrongxuan <hongrongxuan@huawei.com>

 Conflicts:
	drivers/gpio/gpiolib-acpi.c
parent a63b3e13
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -95,10 +95,8 @@ static bool acpi_gpio_deferred_req_irqs_done;

static int acpi_gpiochip_find(struct gpio_chip *gc, void *data)
{
	if (!gc->parent)
		return false;

	return ACPI_HANDLE(gc->parent) == data;
	return device_match_acpi_handle(&gc->gpiodev->dev, data) ||
		(gc->parent && device_match_acpi_handle(gc->parent, data));
}

/**