Module: xenomai-3
Branch: stable-3.0.x
Commit: a2262d5b85f35df485b726c93783a28336024850
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a2262d5b85f35df485b726c93783a28336024850

Author: Philippe Gerum <r...@xenomai.org>
Date:   Thu Apr 19 10:21:01 2018 +0200

drivers/gpio: core: add OF-based scanner searching for multiple compat strings

---

 include/cobalt/kernel/rtdm/gpio.h |    4 ++++
 kernel/drivers/gpio/gpio-core.c   |   19 +++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/include/cobalt/kernel/rtdm/gpio.h 
b/include/cobalt/kernel/rtdm/gpio.h
index 378a678..cdb472f 100644
--- a/include/cobalt/kernel/rtdm/gpio.h
+++ b/include/cobalt/kernel/rtdm/gpio.h
@@ -65,6 +65,10 @@ int rtdm_gpiochip_post_event(struct rtdm_gpio_chip *rgc,
 int rtdm_gpiochip_scan_of(struct device_node *from,
                          const char *compat, int type);
 
+int rtdm_gpiochip_scan_array_of(struct device_node *from,
+                               const char *compat[],
+                               int nentries, int type);
+
 void rtdm_gpiochip_remove_of(int type);
 
 #endif
diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c
index 3e97547..a27c9ee 100644
--- a/kernel/drivers/gpio/gpio-core.c
+++ b/kernel/drivers/gpio/gpio-core.c
@@ -571,6 +571,25 @@ int rtdm_gpiochip_scan_of(struct device_node *from, const 
char *compat,
 }
 EXPORT_SYMBOL_GPL(rtdm_gpiochip_scan_of);
 
+int rtdm_gpiochip_scan_array_of(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_scan_of(from, compat[n], type);
+               if (_ret) {
+                       if (_ret != -ENODEV)
+                               return _ret;
+               } else
+                       ret = 0;
+       }
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(rtdm_gpiochip_scan_array_of);
+
 void rtdm_gpiochip_remove_of(int type)
 {
        struct rtdm_gpio_chip *rgc, *n;


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git

Reply via email to