All of lore.kernel.org
 help / color / mirror / Atom feed
From: hongzha1 <hongzhan.chen@intel.com>
To: xenomai@xenomai.org
Subject: [PATCH 2/3] drivers/gpio: core: introduce helper to find gpiochip
Date: Tue, 13 Apr 2021 22:16:24 -0400	[thread overview]
Message-ID: <20210414021625.24725-2-hongzhan.chen@intel.com> (raw)
In-Reply-To: <20210414021625.24725-1-hongzhan.chen@intel.com>

To find gpiochip for non-OF platforms like x86

Signed-off-by: hongzha1 <hongzhan.chen@intel.com>

diff --git a/include/cobalt/kernel/rtdm/gpio.h b/include/cobalt/kernel/rtdm/gpio.h
index 00055ec0a..c5fb20f25 100644
--- a/include/cobalt/kernel/rtdm/gpio.h
+++ b/include/cobalt/kernel/rtdm/gpio.h
@@ -61,6 +61,9 @@ 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);
+
 #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 600ef9789..b3d801fa1 100644
--- a/kernel/drivers/gpio/gpio-core.c
+++ b/kernel/drivers/gpio/gpio-core.c
@@ -520,6 +520,29 @@ 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);
+
 #ifdef CONFIG_OF
 
 #include <linux/of_platform.h>
-- 
2.17.1



  reply	other threads:[~2021-04-14  2:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-14  2:16 [PATCH 1/3] rtdm/testing: latmus: introduce latmus driver hongzha1
2021-04-14  2:16 ` hongzha1 [this message]
2021-04-14  2:16 ` [PATCH 3/3] testsuite/latmus: introduce latmus benchmark hongzha1
2021-04-14  9:08 ` [PATCH 1/3] rtdm/testing: latmus: introduce latmus driver Jan Kiszka
2021-04-15  0:56   ` Chen, Hongzhan
2021-04-15  7:47   ` Philippe Gerum
2021-08-30  6:45 [PATCH 0/3] add support for cherryview gpio controller driver Hongzhan Chen
2021-08-30  6:45 ` [PATCH 2/3] drivers/gpio: core: Introduce helper to find gpiochip Hongzhan Chen
2021-08-31  5:07 [PATCH V2 0/3] add support for cherryview gpio controller driver Hongzhan Chen
2021-08-31  5:07 ` [PATCH 2/3] drivers/gpio: core: Introduce helper to find gpiochip Hongzhan Chen
2021-08-31  6:47   ` Jan Kiszka
2021-08-31  7:07     ` Chen, Hongzhan
2021-08-31  7:14       ` Jan Kiszka

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=20210414021625.24725-2-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.