Thomas Gleixner | dd3a1db | 2008-10-16 18:20:58 +0200 | [diff] [blame] | 1 | #ifndef _LINUX_IRQNR_H |
| 2 | #define _LINUX_IRQNR_H |
| 3 | |
Ingo Molnar | 0ebb26e | 2008-12-12 11:26:39 +0100 | [diff] [blame] | 4 | /* |
| 5 | * Generic irq_desc iterators: |
| 6 | */ |
| 7 | #ifdef __KERNEL__ |
| 8 | |
Thomas Gleixner | dd3a1db | 2008-10-16 18:20:58 +0200 | [diff] [blame] | 9 | #ifndef CONFIG_GENERIC_HARDIRQS |
| 10 | #include <asm/irq.h> |
Ingo Molnar | be92d7a | 2009-01-05 14:34:42 +0100 | [diff] [blame] | 11 | |
| 12 | /* |
| 13 | * Wrappers for non-genirq architectures: |
| 14 | */ |
| 15 | #define nr_irqs NR_IRQS |
| 16 | #define irq_to_desc(irq) (&irq_desc[irq]) |
Thomas Gleixner | dd3a1db | 2008-10-16 18:20:58 +0200 | [diff] [blame] | 17 | |
| 18 | # define for_each_irq_desc(irq, desc) \ |
| 19 | for (irq = 0; irq < nr_irqs; irq++) |
Thomas Gleixner | dd3a1db | 2008-10-16 18:20:58 +0200 | [diff] [blame] | 20 | |
Yinghai Lu | 240d367 | 2008-12-08 14:06:17 -0800 | [diff] [blame] | 21 | # define for_each_irq_desc_reverse(irq, desc) \ |
| 22 | for (irq = nr_irqs - 1; irq >= 0; irq--) |
Mike Travis | 9332fcc | 2009-01-10 22:24:07 -0800 | [diff] [blame] | 23 | |
KOSAKI Motohiro | f9af0e7 | 2008-12-26 12:24:24 +0900 | [diff] [blame] | 24 | #else /* CONFIG_GENERIC_HARDIRQS */ |
Ingo Molnar | 0ebb26e | 2008-12-12 11:26:39 +0100 | [diff] [blame] | 25 | |
| 26 | extern int nr_irqs; |
KOSAKI Motohiro | f9af0e7 | 2008-12-26 12:24:24 +0900 | [diff] [blame] | 27 | extern struct irq_desc *irq_to_desc(unsigned int irq); |
Ingo Molnar | 0ebb26e | 2008-12-12 11:26:39 +0100 | [diff] [blame] | 28 | |
KOSAKI Motohiro | f9af0e7 | 2008-12-26 12:24:24 +0900 | [diff] [blame] | 29 | # define for_each_irq_desc(irq, desc) \ |
| 30 | for (irq = 0, desc = irq_to_desc(irq); irq < nr_irqs; \ |
KOSAKI Motohiro | 18eefed | 2008-12-26 12:29:48 +0900 | [diff] [blame] | 31 | irq++, desc = irq_to_desc(irq)) \ |
KOSAKI Motohiro | 01d0782 | 2009-01-04 03:11:05 +0900 | [diff] [blame] | 32 | if (!desc) \ |
| 33 | ; \ |
| 34 | else |
KOSAKI Motohiro | 18eefed | 2008-12-26 12:29:48 +0900 | [diff] [blame] | 35 | |
| 36 | |
KOSAKI Motohiro | f9af0e7 | 2008-12-26 12:24:24 +0900 | [diff] [blame] | 37 | # define for_each_irq_desc_reverse(irq, desc) \ |
| 38 | for (irq = nr_irqs - 1, desc = irq_to_desc(irq); irq >= 0; \ |
KOSAKI Motohiro | 18eefed | 2008-12-26 12:29:48 +0900 | [diff] [blame] | 39 | irq--, desc = irq_to_desc(irq)) \ |
KOSAKI Motohiro | 01d0782 | 2009-01-04 03:11:05 +0900 | [diff] [blame] | 40 | if (!desc) \ |
| 41 | ; \ |
| 42 | else |
Yinghai Lu | 240d367 | 2008-12-08 14:06:17 -0800 | [diff] [blame] | 43 | |
KOSAKI Motohiro | f9af0e7 | 2008-12-26 12:24:24 +0900 | [diff] [blame] | 44 | #endif /* CONFIG_GENERIC_HARDIRQS */ |
Yinghai Lu | 240d367 | 2008-12-08 14:06:17 -0800 | [diff] [blame] | 45 | |
| 46 | #define for_each_irq_nr(irq) \ |
| 47 | for (irq = 0; irq < nr_irqs; irq++) |
Thomas Gleixner | dd3a1db | 2008-10-16 18:20:58 +0200 | [diff] [blame] | 48 | |
Ingo Molnar | 0ebb26e | 2008-12-12 11:26:39 +0100 | [diff] [blame] | 49 | #endif /* __KERNEL__ */ |
| 50 | |
Thomas Gleixner | dd3a1db | 2008-10-16 18:20:58 +0200 | [diff] [blame] | 51 | #endif |