From: Hongzhan Chen <hongzhan.chen@intel.com>
To: xenomai@xenomai.org
Subject: [PATCH 2/3] drivers/gpio: core: Introduce helper to find gpiochip
Date: Tue, 31 Aug 2021 01:07:35 -0400 [thread overview]
Message-ID: <20210831050736.5371-3-hongzhan.chen@intel.com> (raw)
In-Reply-To: <20210831050736.5371-1-hongzhan.chen@intel.com>
To find gpiochip for non-OF platforms like x86
Signed-off-by: Hongzhan Chen <hongzhan.chen@intel.com>
---
include/cobalt/kernel/rtdm/gpio.h | 7 ++++++
kernel/drivers/gpio/gpio-core.c | 42 +++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+)
diff --git a/include/cobalt/kernel/rtdm/gpio.h b/include/cobalt/kernel/rtdm/gpio.h
index 29f26d6c6..98279e242 100644
--- a/include/cobalt/kernel/rtdm/gpio.h
+++ b/include/cobalt/kernel/rtdm/gpio.h
@@ -62,6 +62,13 @@ int rtdm_gpiochip_add_by_name(struct rtdm_gpio_chip *rgc,
int rtdm_gpiochip_post_event(struct rtdm_gpio_chip *rgc,
unsigned int offset);
+int rtdm_gpiochip_find(struct device_node *from,
+ const char *label, int type);
+
+int rtdm_gpiochip_array_find(struct device_node *from,
+ const char *compat[],
+ int nentries, int type);
+
#ifdef CONFIG_OF
int rtdm_gpiochip_scan_of(struct device_node *from,
diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c
index ccda67bd1..ce80e8d73 100644
--- a/kernel/drivers/gpio/gpio-core.c
+++ b/kernel/drivers/gpio/gpio-core.c
@@ -528,6 +528,48 @@ int rtdm_gpiochip_add_by_name(struct rtdm_gpio_chip *rgc,
}
EXPORT_SYMBOL_GPL(rtdm_gpiochip_add_by_name);
+int rtdm_gpiochip_find(struct device_node *from, const char *label,
+ int type)
+{
+ struct rtdm_gpio_chip *rgc;
+ struct gpio_chip *chip;
+ int ret = -ENODEV;
+
+ if (!rtdm_available())
+ return -ENOSYS;
+
+ chip = find_chip_by_name(label);
+ if (chip == NULL)
+ return ret;
+
+ ret = 0;
+ rgc = rtdm_gpiochip_alloc(chip, type);
+ if (IS_ERR(rgc))
+ ret = PTR_ERR(rgc);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(rtdm_gpiochip_find);
+
+int rtdm_gpiochip_array_find(struct device_node *from,
+ const char *compat[],
+ int nentries, int type)
+{
+ int ret = -ENODEV, _ret, n;
+
+ for (n = 0; n < nentries; n++) {
+ _ret = rtdm_gpiochip_find(from, compat[n], type);
+ if (_ret) {
+ if (_ret != -ENODEV)
+ return _ret;
+ } else
+ ret = 0;
+ }
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(rtdm_gpiochip_array_find);
+
#ifdef CONFIG_OF
#include <linux/of_platform.h>
--
2.17.1
next prev parent reply other threads:[~2021-08-31 5:07 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-31 5:07 [PATCH V2 0/3] add support for cherryview gpio controller driver Hongzhan Chen
2021-08-31 5:07 ` [PATCH 1/3] drivers/gpio: core: Move out of OF config conditional compilation Hongzhan Chen
2021-08-31 13:05 ` Jan Kiszka
2021-09-01 1:16 ` Chen, Hongzhan
2021-08-31 5:07 ` Hongzhan Chen [this message]
2021-08-31 6:47 ` [PATCH 2/3] drivers/gpio: core: Introduce helper to find gpiochip Jan Kiszka
2021-08-31 7:07 ` Chen, Hongzhan
2021-08-31 7:14 ` Jan Kiszka
2021-08-31 5:07 ` [PATCH 3/3] driver/gpio: Add Intel Cherryview pinctrl driver Hongzhan Chen
2021-08-31 6:51 ` Jan Kiszka
2021-08-31 7:15 ` [PATCH V2 0/3] add support for cherryview gpio controller driver Jan Kiszka
-- strict thread matches above, loose matches on Subject: below --
2021-08-30 6:45 [PATCH " Hongzhan Chen
2021-08-30 6:45 ` [PATCH 2/3] drivers/gpio: core: Introduce helper to find gpiochip Hongzhan Chen
2021-04-14 2:16 [PATCH 1/3] rtdm/testing: latmus: introduce latmus driver hongzha1
2021-04-14 2:16 ` [PATCH 2/3] drivers/gpio: core: introduce helper to find gpiochip hongzha1
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=20210831050736.5371-3-hongzhan.chen@intel.com \
--to=hongzhan.chen@intel.com \
--cc=xenomai@xenomai.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.