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> |
| 11 | # define nr_irqs NR_IRQS |
| 12 | |
| 13 | # define for_each_irq_desc(irq, desc) \ |
| 14 | for (irq = 0; irq < nr_irqs; irq++) |
Thomas Gleixner | dd3a1db | 2008-10-16 18:20:58 +0200 | [diff] [blame] | 15 | |
Yinghai Lu | 240d367 | 2008-12-08 14:06:17 -0800 | [diff] [blame] | 16 | # define for_each_irq_desc_reverse(irq, desc) \ |
| 17 | for (irq = nr_irqs - 1; irq >= 0; irq--) |
KOSAKI Motohiro | f9af0e7 | 2008-12-26 12:24:24 +0900 | [diff] [blame] | 18 | #else /* CONFIG_GENERIC_HARDIRQS */ |
Ingo Molnar | 0ebb26e | 2008-12-12 11:26:39 +0100 | [diff] [blame] | 19 | |
| 20 | extern int nr_irqs; |
KOSAKI Motohiro | f9af0e7 | 2008-12-26 12:24:24 +0900 | [diff] [blame] | 21 | extern struct irq_desc *irq_to_desc(unsigned int irq); |
Ingo Molnar | 0ebb26e | 2008-12-12 11:26:39 +0100 | [diff] [blame] | 22 | |
KOSAKI Motohiro | f9af0e7 | 2008-12-26 12:24:24 +0900 | [diff] [blame] | 23 | # define for_each_irq_desc(irq, desc) \ |
| 24 | for (irq = 0, desc = irq_to_desc(irq); irq < nr_irqs; \ |
KOSAKI Motohiro | 18eefed | 2008-12-26 12:29:48 +0900 | [diff] [blame^] | 25 | irq++, desc = irq_to_desc(irq)) \ |
| 26 | if (desc) |
| 27 | |
| 28 | |
KOSAKI Motohiro | f9af0e7 | 2008-12-26 12:24:24 +0900 | [diff] [blame] | 29 | # define for_each_irq_desc_reverse(irq, desc) \ |
| 30 | for (irq = nr_irqs - 1, desc = irq_to_desc(irq); irq >= 0; \ |
KOSAKI Motohiro | 18eefed | 2008-12-26 12:29:48 +0900 | [diff] [blame^] | 31 | irq--, desc = irq_to_desc(irq)) \ |
| 32 | if (desc) |
Yinghai Lu | 240d367 | 2008-12-08 14:06:17 -0800 | [diff] [blame] | 33 | |
KOSAKI Motohiro | f9af0e7 | 2008-12-26 12:24:24 +0900 | [diff] [blame] | 34 | #endif /* CONFIG_GENERIC_HARDIRQS */ |
Yinghai Lu | 240d367 | 2008-12-08 14:06:17 -0800 | [diff] [blame] | 35 | |
| 36 | #define for_each_irq_nr(irq) \ |
| 37 | for (irq = 0; irq < nr_irqs; irq++) |
Thomas Gleixner | dd3a1db | 2008-10-16 18:20:58 +0200 | [diff] [blame] | 38 | |
Ingo Molnar | 0ebb26e | 2008-12-12 11:26:39 +0100 | [diff] [blame] | 39 | #endif /* __KERNEL__ */ |
| 40 | |
Thomas Gleixner | dd3a1db | 2008-10-16 18:20:58 +0200 | [diff] [blame] | 41 | #endif |