linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Linus Walleij <linus.walleij@linaro.org>,
	Alexandre Courbot <gnurou@gmail.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	linux-gpio@vger.kernel.org, Hans de Goede <hdegoede@redhat.com>
Subject: [PATCH 2/2] gpio: acpi: acpi_dev_gpio_irq_get: ignore the status of unselected irqs
Date: Fri, 10 Mar 2017 21:58:46 +0100	[thread overview]
Message-ID: <20170310205846.16530-3-hdegoede@redhat.com> (raw)
In-Reply-To: <20170310205846.16530-1-hdegoede@redhat.com>

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@redhat.com>
---
 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


  parent reply	other threads:[~2017-03-10 20:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-10 20:58 [PATCH 0/2] gpio: acpi: acpi_dev_gpio_irq_get: ignore the status of unselected irqs Hans de Goede
2017-03-10 20:58 ` [PATCH 1/2] gpio: acpi: acpi_gpio_resource_lookup: return info even if there is no desc Hans de Goede
2017-03-15 10:17   ` Linus Walleij
2017-03-15 10:19     ` Hans de Goede
2017-03-10 20:58 ` Hans de Goede [this message]
2017-03-13 17:23 ` [PATCH 0/2] gpio: acpi: acpi_dev_gpio_irq_get: ignore the status of unselected irqs Andy Shevchenko
2017-03-13 17:56   ` Hans de Goede
2017-03-13 19:19     ` Andy Shevchenko
2017-03-13 19:23       ` Hans de Goede
2017-03-13 19:31         ` Andy Shevchenko
2017-03-13 19:38           ` Andy Shevchenko
2017-03-13 22:02             ` Hans de Goede

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170310205846.16530-3-hdegoede@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=gnurou@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).