devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] of/irq: introduce of_has_named_irqs helper
@ 2015-07-24 18:26 Dmitry Torokhov
  2015-07-24 19:14 ` Rob Herring
  2015-07-24 19:35 ` Florian Fainelli
  0 siblings, 2 replies; 12+ messages in thread
From: Dmitry Torokhov @ 2015-07-24 18:26 UTC (permalink / raw)
  To: Grant Likely; +Cc: Rob Herring, devicetree, linux-kernel

Sometimes drivers might wish to transition from index-based to named
interrupt descriptions. To aid in decision-making when parsing device
tree data let's provide a helper that will indicate the scheme that is
being used.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---

The intent is to it like this:

	if (of_has_named_irqs(np) {
		/* Wake IRQ is optional */
		dev->wakeirq = of_irq_get_byname(np, "wakeup");
		if (dev->wakeirq < 0 && dev->wakeirq != -ENODATA)
			return dev->wakeirq;
	}

 drivers/of/irq.c       | 14 ++++++++++++++
 include/linux/of_irq.h |  5 +++++
 2 files changed, 19 insertions(+)

diff --git a/drivers/of/irq.c b/drivers/of/irq.c
index 3cf7a01..e02c43e 100644
--- a/drivers/of/irq.c
+++ b/drivers/of/irq.c
@@ -384,6 +384,19 @@ int of_irq_to_resource(struct device_node *dev, int index, struct resource *r)
 EXPORT_SYMBOL_GPL(of_irq_to_resource);
 
 /**
+ * of_has_named_irq - Check if given node contains named interrupts
+ * @dev: pointer to device tree node
+ *
+ * Returns %true if node contains non-empty "interrupt-names" property.
+ */
+bool of_has_named_irqs(struct device_node *dev)
+{
+	struct property *prop = of_find_property(dev, "interrupt-names", NULL);
+
+	return prop && prop->value;
+}
+
+/**
  * of_irq_get - Decode a node's IRQ and return it as a Linux irq number
  * @dev: pointer to device tree node
  * @index: zero-based index of the irq
@@ -410,6 +423,7 @@ int of_irq_get(struct device_node *dev, int index)
 }
 EXPORT_SYMBOL_GPL(of_irq_get);
 
+
 /**
  * of_irq_get_byname - Decode a node's IRQ and return it as a Linux irq number
  * @dev: pointer to device tree node
diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h
index d884929..fed6ccc 100644
--- a/include/linux/of_irq.h
+++ b/include/linux/of_irq.h
@@ -46,6 +46,7 @@ extern int of_irq_get(struct device_node *dev, int index);
 extern int of_irq_get_byname(struct device_node *dev, const char *name);
 extern int of_irq_to_resource_table(struct device_node *dev,
 		struct resource *res, int nr_irqs);
+extern bool of_has_named_irqs(struct device_node *dev);
 #else
 static inline int of_irq_count(struct device_node *dev)
 {
@@ -64,6 +65,10 @@ static inline int of_irq_to_resource_table(struct device_node *dev,
 {
 	return 0;
 }
+static inline bool of_has_named_irqs(struct device_node *dev)
+{
+	return false;
+}
 #endif
 
 #if defined(CONFIG_OF)
-- 
2.5.0.rc2.392.g76e840b


-- 
Dmitry

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

end of thread, other threads:[~2015-07-29  4:33 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-24 18:26 [PATCH] of/irq: introduce of_has_named_irqs helper Dmitry Torokhov
2015-07-24 19:14 ` Rob Herring
     [not found]   ` <CAL_Jsq+JGpNBwS3HF1fF4HdefRCwhniaYCm5G4_WAnio7t-1og-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-07-24 19:26     ` Dmitry Torokhov
2015-07-24 20:16       ` Dmitry Torokhov
2015-07-28 13:23         ` Vignesh R
     [not found]           ` <55B78268.4040603-l0cyMroinI0@public.gmane.org>
2015-07-28 17:23             ` Dmitry Torokhov
2015-07-28 17:46               ` R, Vignesh
2015-07-28 18:07                 ` Dmitry Torokhov
2015-07-29  4:33                   ` Vignesh R
2015-07-24 20:59       ` Rob Herring
2015-07-24 21:22         ` Dmitry Torokhov
2015-07-24 19:35 ` Florian Fainelli

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