Skip to contentSkip to conversation

gpio: acpi: Ignore -EPROBE_DEFER for unselected gpioints

PATCH In review Hans de Goede 3 participants 6 messages Mar 13, 2017 – Mar 16, 2017 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 gpio: acpi: Ignore -EPROBE_DEFER for unselected gpioints

When acpi_dev_gpio_irq_get gets called with an index of say 2, it should not care if acpi_get_gpiod for index 0 or 1 returns -EPROBE_DEFER.

This allows drivers which request a gpioint with index > 0 to function if there is no gpiochip driver (loaded) for gpioints with a lower index.

---
 drivers/gpio/gpiolib-acpi.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
drivers/gpio/gpiolib-acpi.c +11 -7
index 9b37a36..8cd3f66 100644
@@ -653,20 +653,24 @@ int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
 {
 	int idx, i;
 	unsigned int irq_flags;
-	int ret = -ENOENT;
 
 	for (i = 0, idx = 0; idx <= index; i++) {
 		struct acpi_gpio_info info;
 		struct gpio_desc *desc;
 
 		desc = acpi_get_gpiod_by_index(adev, NULL, i, &info);
-		if (IS_ERR(desc)) {
-			ret = PTR_ERR(desc);
-			break;
-		}
+
+		/* Ignore -EPROBE_DEFER, it only matters if idx matches */
+		if (IS_ERR(desc) && PTR_ERR(desc) != -EPROBE_DEFER)
+			return PTR_ERR(desc);
+
 		if (info.gpioint && idx++ == index) {
-			int irq = gpiod_to_irq(desc);
+			int irq;
+
+			if (IS_ERR(desc))
+				return PTR_ERR(desc);
 
+			irq = gpiod_to_irq(desc);
 			if (irq < 0)
 				return irq;
 
@@ -682,7 +686,7 @@ int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
 		}
 
 	}
-	return ret;
+	return -ENOENT;
 }
 EXPORT_SYMBOL_GPL(acpi_dev_gpio_irq_get);
 
Signature · 1 line
2.9.3
#1 lore raw

Hi,

A note about the v2 in the subject, this patch moving from me to Andy and back again has resulted in the inline changelog being eaten.

This is basically a new patch replacing my 2 patch series which tried to deal with -EPROBE_DEFER errors for not selected gpioints. It uses a different (simpler) approach then that series.

Regards,

Hans

Quoted 57 lines · Hans de Goede

When acpi_dev_gpio_irq_get gets called with an index of say 2, it should not care if acpi_get_gpiod for index 0 or 1 returns -EPROBE_DEFER.

This allows drivers which request a gpioint with index > 0 to function if there is no gpiochip driver (loaded) for gpioints with a lower index.

---
 drivers/gpio/gpiolib-acpi.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
drivers/gpio/gpiolib-acpi.c +11 -7
index 9b37a36..8cd3f66 100644
@@ -653,20 +653,24 @@ int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
 {
 	int idx, i;
 	unsigned int irq_flags;
-	int ret = -ENOENT;
 
 	for (i = 0, idx = 0; idx <= index; i++) {
 		struct acpi_gpio_info info;
 		struct gpio_desc *desc;
 
 		desc = acpi_get_gpiod_by_index(adev, NULL, i, &info);
-		if (IS_ERR(desc)) {
-			ret = PTR_ERR(desc);
-			break;
-		}
+
+		/* Ignore -EPROBE_DEFER, it only matters if idx matches */
+		if (IS_ERR(desc) && PTR_ERR(desc) != -EPROBE_DEFER)
+			return PTR_ERR(desc);
+
 		if (info.gpioint && idx++ == index) {
-			int irq = gpiod_to_irq(desc);
+			int irq;
+
+			if (IS_ERR(desc))
+				return PTR_ERR(desc);
 
+			irq = gpiod_to_irq(desc);
 			if (irq < 0)
 				return irq;
 
@@ -682,7 +686,7 @@ int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
 		}
 
 	}
-	return ret;
+	return -ENOENT;
 }
 EXPORT_SYMBOL_GPL(acpi_dev_gpio_irq_get);
 
#2 lore raw
In reply to Hans de Goede
Quoted 8 lines · Hans de Goede

When acpi_dev_gpio_irq_get gets called with an index of say 2, it should not care if acpi_get_gpiod for index 0 or 1 returns -EPROBE_DEFER.

This allows drivers which request a gpioint with index > 0 to function if there is no gpiochip driver (loaded) for gpioints with a lower index.

I am dependent on Mika and Rafael to review ACPI/GPIO patches, maybe I should just put in a special entry to MAINTAINERS for this file... anyway let's see what they say.

Yours,
Linus Walleij

#3 lore raw
Quoted 8 lines · Linus Walleij
Quoted 6 lines · Hans de Goede

When acpi_dev_gpio_irq_get gets called with an index of say 2, it should not care if acpi_get_gpiod for index 0 or 1 returns -EPROBE_DEFER.

This allows drivers which request a gpioint with index > 0 to function if there is no gpiochip driver (loaded) for gpioints with a lower index.

Quoted 6 lines
Quoted 2 lines

I am dependent on Mika and Rafael to review ACPI/GPIO patches, maybe I should just put in a special entry to MAINTAINERS for this file... anyway let's see what they say.

Hans, could you in future Cc patches related to ACPI to linux-acpi mailing list as well? This one I looked up from linux-gpio mail archives.

The patch looks good to me so,

#4 lore raw

Hi,

Quoted 12 lines · Mika Westerberg
Quoted 11 lines · Linus Walleij
Quoted 8 lines · Hans de Goede

When acpi_dev_gpio_irq_get gets called with an index of say 2, it should not care if acpi_get_gpiod for index 0 or 1 returns -EPROBE_DEFER.

This allows drivers which request a gpioint with index > 0 to function if there is no gpiochip driver (loaded) for gpioints with a lower index.

Quoted 6 lines
Quoted 3 lines

I am dependent on Mika and Rafael to review ACPI/GPIO patches, maybe I should just put in a special entry to MAINTAINERS for this file... anyway let's see what they say.

Hans, could you in future Cc patches related to ACPI to linux-acpi mailing list as well?

Ok, will do.

Quoted 6 lines

This one I looked up from linux-gpio mail
archives.

The patch looks good to me so,

Thank you.

Regards,

Hans

#5 lore raw
In reply to Hans de Goede
Quoted 8 lines · Hans de Goede

When acpi_dev_gpio_irq_get gets called with an index of say 2, it should not care if acpi_get_gpiod for index 0 or 1 returns -EPROBE_DEFER.

This allows drivers which request a gpioint with index > 0 to function if there is no gpiochip driver (loaded) for gpioints with a lower index.

Patch applied with Mika's ACK.

Yours,
Linus Walleij