devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] of/irq: do irq resolution in platform_get_irq_byname()
@ 2014-05-20 10:42 Grygorii Strashko
  2014-05-23  8:03 ` Grant Likely
  0 siblings, 1 reply; 15+ messages in thread
From: Grygorii Strashko @ 2014-05-20 10:42 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring, Grant Likely
  Cc: santosh.shilimkar-l0cyMroinI0,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	Grygorii Strashko, Russell King, Rob Herring, Tony Lindgren,
	Thierry Reding

The commit 9ec36cafe43bf835f8f29273597a5b0cbc8267ef
"of/irq: do irq resolution in platform_get_irq" from Rob Herring -
moves resolving of the interrupt resources in platform_get_irq().
But this solution isn't complete because platform_get_irq_byname()
need to be modified the same way.

Hence, fix it by adding interrupt resolution code at the
platform_get_irq_byname() function too.

Cc: Russell King <linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org>
Cc: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
Cc: Grant Likely <grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: Thierry Reding <thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Signed-off-by: Grygorii Strashko <grygorii.strashko-l0cyMroinI0@public.gmane.org>
---
Changes in v1:
- use of_property_match_string() to get IRQ index by name
- minor comments fixed

RFC:
 https://lkml.org/lkml/2014/5/19/325

 drivers/base/platform.c |    7 +++++--
 drivers/of/irq.c        |   22 ++++++++++++++++++++++
 include/linux/of_irq.h  |    5 +++++
 3 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 5b47210..9e9227e 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -131,9 +131,12 @@ EXPORT_SYMBOL_GPL(platform_get_resource_byname);
  */
 int platform_get_irq_byname(struct platform_device *dev, const char *name)
 {
-	struct resource *r = platform_get_resource_byname(dev, IORESOURCE_IRQ,
-							  name);
+	struct resource *r;
+
+	if (IS_ENABLED(CONFIG_OF_IRQ) && dev->dev.of_node)
+		return of_irq_get_byname(dev->dev.of_node, name);
 
+	r = platform_get_resource_byname(dev, IORESOURCE_IRQ, name);
 	return r ? r->start : -ENXIO;
 }
 EXPORT_SYMBOL_GPL(platform_get_irq_byname);
diff --git a/drivers/of/irq.c b/drivers/of/irq.c
index 5aeb894..3e06a69 100644
--- a/drivers/of/irq.c
+++ b/drivers/of/irq.c
@@ -406,6 +406,28 @@ int of_irq_get(struct device_node *dev, int index)
 }
 
 /**
+ * of_irq_get_byname - Decode a node's IRQ and return it as a Linux irq number
+ * @dev: pointer to device tree node
+ * @name: irq name
+ *
+ * Returns Linux irq number on success, or -EPROBE_DEFER if the irq domain
+ * is not yet created, or error code in case of any other failure.
+ */
+int of_irq_get_byname(struct device_node *dev, const char *name)
+{
+	int index;
+
+	if (unlikely(!name))
+		return -EINVAL;
+
+	index = of_property_match_string(dev, "interrupt-names", name);
+	if (index < 0)
+		return index;
+
+	return of_irq_get(dev, index);
+}
+
+/**
  * of_irq_count - Count the number of IRQs a node uses
  * @dev: pointer to device tree node
  */
diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h
index 6404253..bfec136 100644
--- a/include/linux/of_irq.h
+++ b/include/linux/of_irq.h
@@ -45,6 +45,7 @@ extern void of_irq_init(const struct of_device_id *matches);
 #ifdef CONFIG_OF_IRQ
 extern int of_irq_count(struct device_node *dev);
 extern int of_irq_get(struct device_node *dev, int index);
+extern int of_irq_get_byname(struct device_node *dev, const char *name);
 #else
 static inline int of_irq_count(struct device_node *dev)
 {
@@ -54,6 +55,10 @@ static inline int of_irq_get(struct device_node *dev, int index)
 {
 	return 0;
 }
+static inline int of_irq_get_byname(struct device_node *dev, const char *name)
+{
+	return 0;
+}
 #endif
 
 #if defined(CONFIG_OF)
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2014-06-11 14:04 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-20 10:42 [PATCH v1] of/irq: do irq resolution in platform_get_irq_byname() Grygorii Strashko
2014-05-23  8:03 ` Grant Likely
     [not found]   ` <20140523080333.66720C4176E-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2014-05-27 20:23     ` Kevin Hilman
2014-05-28  0:37       ` Rob Herring
     [not found]         ` <CAL_JsqLm3wfVS+au+JUbhBhxz=LuVpepH6GxabCQhPowhbw77g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-05-28  7:18           ` Lee Jones
2014-05-28  8:25             ` Linus Walleij
2014-05-28  8:49               ` Chen-Yu Tsai
     [not found]                 ` <CAGb2v64f8Wju6dtVuVN2x=9YVGA-=RXozzhpJZNspKZ05f=jtA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-05-28  9:03                   ` Grant Likely
     [not found]                     ` <CACxGe6ts-TcSKk2F0-XSxAxeTxVCiyDHgh-O12v+F2OjHUsPyg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-05-28 10:07                       ` Grygorii Strashko
     [not found]                         ` <5385B566.2050600-l0cyMroinI0@public.gmane.org>
2014-06-02 14:48                           ` Kevin Hilman
     [not found]                             ` <7h7g4zz7s4.fsf-4poPxKt068f/PtFMR13I2A@public.gmane.org>
2014-06-03  9:20                               ` Grant Likely
     [not found]                                 ` <20140603092050.F0FD0C40D3B-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2014-06-03 11:12                                   ` Grygorii Strashko
2014-06-11 14:04                   ` Linus Walleij
2014-05-28  8:39           ` Grant Likely
2014-05-28  9:49         ` Grygorii Strashko

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).