[PATCH 2/2] gpio: acpi: acpi_dev_gpio_irq_get: ignore the status of unselected irqs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When acpi_dev_gpio_irq_get gets called with an index of say 2, it
should not care if the gpioint matching index 0 or 1 has a valid
descriptor.

Before this commit acpi_dev_gpio_irq_get would exit on the first gpioint
with an invalid descriptor it would encounter, this commit modifies it to
only care if the gpioint with the requested index has a valid descriptor.

Signed-off-by: Hans de Goede <hdegoede@xxxxxxxxxx>
---
 drivers/gpio/gpiolib-acpi.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index 86fabdd..11bd1a6 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -746,21 +746,27 @@ struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode,
 int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
 {
 	unsigned int irq_flags;
-	int idx, i;
+	int idx, i, irq, ret;
 
 	for (i = 0, idx = 0; idx <= index; i++) {
 		struct acpi_gpio_info info;
-		struct gpio_desc *desc;
+		struct acpi_gpio_lookup lookup;
 
-		desc = acpi_get_gpiod_by_index(adev, NULL, i, &info);
-		if (IS_ERR(desc))
-			return PTR_ERR(desc);
+		memset(&lookup, 0, sizeof(lookup));
+		lookup.index = index;
+		lookup.adev = adev;
+		ret = acpi_gpio_resource_lookup(&lookup, &info);
+		if (!lookup.found)
+			return ret;
 
 		if (info.gpioint && idx++ == index) {
-			int irq = gpiod_to_irq(desc);
+			struct gpio_desc *desc = lookup.desc;
 			char label[32];
-			int ret;
 
+			if (!desc)
+				return ret;
+
+			irq = gpiod_to_irq(desc);
 			if (irq < 0)
 				return irq;
 
-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux