aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/of/irq.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/of/irq.c')
-rw-r--r--drivers/of/irq.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/drivers/of/irq.c b/drivers/of/irq.c
index 6e595e5a3977..9f689f1da0fc 100644
--- a/drivers/of/irq.c
+++ b/drivers/of/irq.c
@@ -24,6 +24,11 @@
24#include <linux/of_irq.h> 24#include <linux/of_irq.h>
25#include <linux/string.h> 25#include <linux/string.h>
26 26
27/* For archs that don't support NO_IRQ (such as x86), provide a dummy value */
28#ifndef NO_IRQ
29#define NO_IRQ 0
30#endif
31
27/** 32/**
28 * irq_of_parse_and_map - Parse and map an interrupt into linux virq space 33 * irq_of_parse_and_map - Parse and map an interrupt into linux virq space
29 * @device: Device node of the device whose interrupt is to be mapped 34 * @device: Device node of the device whose interrupt is to be mapped
@@ -51,7 +56,7 @@ EXPORT_SYMBOL_GPL(irq_of_parse_and_map);
51 * Returns a pointer to the interrupt parent node, or NULL if the interrupt 56 * Returns a pointer to the interrupt parent node, or NULL if the interrupt
52 * parent could not be determined. 57 * parent could not be determined.
53 */ 58 */
54static struct device_node *of_irq_find_parent(struct device_node *child) 59struct device_node *of_irq_find_parent(struct device_node *child)
55{ 60{
56 struct device_node *p; 61 struct device_node *p;
57 const __be32 *parp; 62 const __be32 *parp;
@@ -347,3 +352,37 @@ int of_irq_to_resource(struct device_node *dev, int index, struct resource *r)
347 return irq; 352 return irq;
348} 353}
349EXPORT_SYMBOL_GPL(of_irq_to_resource); 354EXPORT_SYMBOL_GPL(of_irq_to_resource);
355
356/**
357 * of_irq_count - Count the number of IRQs a node uses
358 * @dev: pointer to device tree node
359 */
360int of_irq_count(struct device_node *dev)
361{
362 int nr = 0;
363
364 while (of_irq_to_resource(dev, nr, NULL) != NO_IRQ)
365 nr++;
366
367 return nr;
368}
369
370/**
371 * of_irq_to_resource_table - Fill in resource table with node's IRQ info
372 * @dev: pointer to device tree node
373 * @res: array of resources to fill in
374 * @nr_irqs: the number of IRQs (and upper bound for num of @res elements)
375 *
376 * Returns the size of the filled in table (up to @nr_irqs).
377 */
378int of_irq_to_resource_table(struct device_node *dev, struct resource *res,
379 int nr_irqs)
380{
381 int i;
382
383 for (i = 0; i < nr_irqs; i++, res++)
384 if (of_irq_to_resource(dev, i, res) == NO_IRQ)
385 break;
386
387 return i;
388}