From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: linux-gpio@vger.kernel.org
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
Linus Walleij <linus.walleij@linaro.org>,
Grant Likely <grant.likely@secretlab.ca>,
Mathias Nyman <mathias.nyman@linux.intel.com>,
Alexandre Courbot <acourbot@nvidia.com>,
Rob Landley <rob@landley.net>,
linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org,
Mika Westerberg <mika.westerberg@linux.intel.com>
Subject: [PATCH v2 3/5] gpiolib / ACPI: add ACPI support for gpiod_get_index()
Date: Thu, 10 Oct 2013 11:01:09 +0300 [thread overview]
Message-ID: <1381392071-21407-4-git-send-email-mika.westerberg@linux.intel.com> (raw)
In-Reply-To: <1381392071-21407-1-git-send-email-mika.westerberg@linux.intel.com>
gpiod_get_index() and gpiod_get() are now the new preferred way to request
GPIOs. Add support for finding the corresponding GPIO descriptor from ACPI
namespace.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
---
drivers/gpio/gpiolib.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index e2a2cdd..1e099de 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -10,6 +10,7 @@
#include <linux/seq_file.h>
#include <linux/gpio.h>
#include <linux/of_gpio.h>
+#include <linux/acpi_gpio.h>
#include <linux/idr.h>
#include <linux/slab.h>
@@ -2111,6 +2112,12 @@ static struct gpio_desc *of_find_gpio(struct device *dev, const char *id,
}
#endif
+static struct gpio_desc *acpi_find_gpio(struct device *dev, const char *con_id,
+ unsigned int idx, unsigned long *flags)
+{
+ return acpi_get_gpiod_by_index(dev, idx, NULL);
+}
+
static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id,
unsigned int idx, unsigned long *flags)
{
@@ -2192,6 +2199,9 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
if (IS_ENABLED(CONFIG_OF) && dev && dev->of_node) {
dev_dbg(dev, "using device tree for GPIO lookup\n");
desc = of_find_gpio(dev, con_id, idx, &flags);
+ } else if (IS_ENABLED(CONFIG_ACPI) && dev && ACPI_HANDLE(dev)) {
+ dev_dbg(dev, "using ACPI for GPIO lookup\n");
+ desc = acpi_find_gpio(dev, con_id, idx, &flags);
} else {
dev_dbg(dev, "using lookup tables for GPIO lookup");
desc = gpiod_find(dev, con_id, idx, &flags);
--
1.8.4.rc3
next prev parent reply other threads:[~2013-10-10 8:01 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-10 8:01 [PATCH v2 0/5] gpiolib: convert ACPI gpio helpers to gpiod_ interfaces Mika Westerberg
2013-10-10 8:01 ` [PATCH v2 1/5] gpiolib / ACPI: move acpi_gpiochip_free_interrupts next to the request function Mika Westerberg
2013-10-11 11:00 ` Linus Walleij
2013-10-11 16:42 ` Alexandre Courbot
2013-10-14 6:58 ` Linus Walleij
2013-10-14 10:43 ` Mika Westerberg
2013-10-14 16:55 ` Alexandre Courbot
2013-10-10 8:01 ` [PATCH v2 2/5] gpiolib / ACPI: convert to gpiod interfaces Mika Westerberg
2013-10-10 8:01 ` Mika Westerberg [this message]
2013-10-10 8:01 ` [PATCH v2 4/5] gpiolib / ACPI: allow passing GPIOF_ACTIVE_LOW for GpioInt resources Mika Westerberg
2013-10-10 8:01 ` [PATCH v2 5/5] gpiolib / ACPI: document the GPIO descriptor based interface Mika Westerberg
2013-10-19 21:35 ` Linus Walleij
2013-10-21 7:06 ` Mika Westerberg
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=1381392071-21407-4-git-send-email-mika.westerberg@linux.intel.com \
--to=mika.westerberg@linux.intel.com \
--cc=acourbot@nvidia.com \
--cc=grant.likely@secretlab.ca \
--cc=linus.walleij@linaro.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathias.nyman@linux.intel.com \
--cc=rjw@rjwysocki.net \
--cc=rob@landley.net \
/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).