All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Scally <djrscally@gmail.com>
To: "Rafael J . Wysocki" <rafael.j.wysocki@intel.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Daniel Scally <djrscally@gmail.com>,
	Lee Jones <lee.jones@linaro.org>,
	Hans de Goede <hdegoede@redhat.com>,
	Maximilian Luz <luzmaximilian@gmail.com>,
	linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org,
	linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org,
	platform-driver-x86@vger.kernel.org, devel@acpica.org
Cc: Len Brown <lenb@kernel.org>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <bgolaszewski@baylibre.com>,
	Wolfram Sang <wsa@kernel.org>,
	Mark Gross <mgross@linux.intel.com>,
	Robert Moore <robert.moore@intel.com>,
	Erik Kaneda <erik.kaneda@intel.com>,
	laurent.pinchart@ideasonboard.com,
	kieran.bingham@ideasonboard.com
Subject: [PATCH v5 4/6] gpiolib: acpi: Add acpi_gpio_get_io_resource()
Date: Thu,  3 Jun 2021 23:40:05 +0100	[thread overview]
Message-ID: <20210603224007.120560-5-djrscally@gmail.com> (raw)
In-Reply-To: <20210603224007.120560-1-djrscally@gmail.com>

Add a function to verify that a given acpi_resource represents an IO
type GPIO resource, and return it if so.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Daniel Scally <djrscally@gmail.com>
---
Changes since v4:
	- None

 drivers/gpio/gpiolib-acpi.c | 23 +++++++++++++++++++++++
 include/linux/acpi.h        |  7 +++++++
 2 files changed, 30 insertions(+)

diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index 684ddb35d83b..9887bb684575 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -196,6 +196,29 @@ bool acpi_gpio_get_irq_resource(struct acpi_resource *ares,
 }
 EXPORT_SYMBOL_GPL(acpi_gpio_get_irq_resource);
 
+/**
+ * acpi_gpio_get_io_resource - Fetch details of an ACPI resource if it is a GPIO
+ *			       I/O resource or return False if not.
+ * @ares:	Pointer to the ACPI resource to fetch
+ * @agpio:	Pointer to a &struct acpi_resource_gpio to store the output pointer
+ */
+bool acpi_gpio_get_io_resource(struct acpi_resource *ares,
+			       struct acpi_resource_gpio **agpio)
+{
+	struct acpi_resource_gpio *gpio;
+
+	if (ares->type != ACPI_RESOURCE_TYPE_GPIO)
+		return false;
+
+	gpio = &ares->data.gpio;
+	if (gpio->connection_type != ACPI_RESOURCE_GPIO_TYPE_IO)
+		return false;
+
+	*agpio = gpio;
+	return true;
+}
+EXPORT_SYMBOL_GPL(acpi_gpio_get_io_resource);
+
 static void acpi_gpiochip_request_irq(struct acpi_gpio_chip *acpi_gpio,
 				      struct acpi_gpio_event *event)
 {
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 170b9bebdb2b..e8ba7063c000 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -1098,6 +1098,8 @@ void __acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle, const c
 #if defined(CONFIG_ACPI) && defined(CONFIG_GPIOLIB)
 bool acpi_gpio_get_irq_resource(struct acpi_resource *ares,
 				struct acpi_resource_gpio **agpio);
+bool acpi_gpio_get_io_resource(struct acpi_resource *ares,
+			       struct acpi_resource_gpio **agpio);
 int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *name, int index);
 #else
 static inline bool acpi_gpio_get_irq_resource(struct acpi_resource *ares,
@@ -1105,6 +1107,11 @@ static inline bool acpi_gpio_get_irq_resource(struct acpi_resource *ares,
 {
 	return false;
 }
+static inline bool acpi_gpio_get_io_resource(struct acpi_resource *ares,
+					     struct acpi_resource_gpio **agpio)
+{
+	return false;
+}
 static inline int acpi_dev_gpio_irq_get_by(struct acpi_device *adev,
 					   const char *name, int index)
 {
-- 
2.25.1


  parent reply	other threads:[~2021-06-03 22:40 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-03 22:40 [PATCH v5 0/6] Introduce intel_skl_int3472 module Daniel Scally
2021-06-03 22:40 ` [PATCH v5 1/6] ACPI: scan: Extend acpi_walk_dep_device_list() Daniel Scally
2021-06-03 22:40 ` [PATCH v5 2/6] ACPI: scan: Add function to fetch dependent of acpi device Daniel Scally
2021-06-07 14:52   ` Rafael J. Wysocki
2021-06-07 14:52     ` [Devel] " Rafael J. Wysocki
2021-06-03 22:40 ` [PATCH v5 3/6] gpiolib: acpi: Export acpi_get_gpiod() Daniel Scally
2021-06-04 12:59   ` Andy Shevchenko
2021-06-04 14:09     ` Daniel Scally
2021-06-03 22:40 ` Daniel Scally [this message]
2021-06-04 13:01   ` [PATCH v5 4/6] gpiolib: acpi: Add acpi_gpio_get_io_resource() Andy Shevchenko
2021-06-04 14:09     ` Daniel Scally
2021-06-04 14:33       ` Andy Shevchenko
2021-06-04 16:54         ` Daniel Scally
2021-06-03 22:40 ` [PATCH v5 5/6] platform/x86: Add intel_skl_int3472 driver Daniel Scally
2021-06-04  1:31   ` kernel test robot
2021-06-04  1:31     ` kernel test robot
2021-06-05 23:07     ` Daniel Scally
2021-06-05 23:07       ` Daniel Scally
2021-06-04  6:49   ` kernel test robot
2021-06-04  6:49     ` kernel test robot
2021-06-16 17:58   ` Hans de Goede
2021-06-16 18:08     ` Andy Shevchenko
2021-06-16 18:08       ` [Devel] " Andy Shevchenko
2021-06-16 18:13       ` Hans de Goede
2021-06-16 21:42     ` Daniel Scally
2021-06-03 22:40 ` [PATCH v5 6/6] mfd: tps68470: Remove tps68470 MFD driver Daniel Scally
2021-06-17 11:14   ` Hans de Goede
2021-06-08  9:00 ` [PATCH v5 0/6] Introduce intel_skl_int3472 module Hans de Goede
2021-06-08  9:33   ` Laurent Pinchart

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=20210603224007.120560-5-djrscally@gmail.com \
    --to=djrscally@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=devel@acpica.org \
    --cc=erik.kaneda@intel.com \
    --cc=hdegoede@redhat.com \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=lee.jones@linaro.org \
    --cc=lenb@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luzmaximilian@gmail.com \
    --cc=mgross@linux.intel.com \
    --cc=mika.westerberg@linux.intel.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=robert.moore@intel.com \
    --cc=wsa@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.