diff options
Diffstat (limited to 'drivers/of/irq.c')
-rw-r--r-- | drivers/of/irq.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 6e595e5a3977..75b0d3cb7676 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 |
@@ -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 | } |
349 | EXPORT_SYMBOL_GPL(of_irq_to_resource); | 354 | EXPORT_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 | */ | ||
360 | int 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 | */ | ||
378 | int 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 | } | ||