blob: 86af92e9e84c0e3115845bcd3abbc125d28b5088 [file] [log] [blame]
Thomas Gleixnerdd3a1db2008-10-16 18:20:58 +02001#ifndef _LINUX_IRQNR_H
2#define _LINUX_IRQNR_H
3
Ingo Molnar0ebb26e2008-12-12 11:26:39 +01004/*
5 * Generic irq_desc iterators:
6 */
7#ifdef __KERNEL__
8
Thomas Gleixnerdd3a1db2008-10-16 18:20:58 +02009#ifndef CONFIG_GENERIC_HARDIRQS
10#include <asm/irq.h>
Ingo Molnarbe92d7a2009-01-05 14:34:42 +010011
12/*
13 * Wrappers for non-genirq architectures:
14 */
15#define nr_irqs NR_IRQS
16#define irq_to_desc(irq) (&irq_desc[irq])
Thomas Gleixnerdd3a1db2008-10-16 18:20:58 +020017
18# define for_each_irq_desc(irq, desc) \
19 for (irq = 0; irq < nr_irqs; irq++)
Thomas Gleixnerdd3a1db2008-10-16 18:20:58 +020020
Yinghai Lu240d3672008-12-08 14:06:17 -080021# define for_each_irq_desc_reverse(irq, desc) \
22 for (irq = nr_irqs - 1; irq >= 0; irq--)
KOSAKI Motohirof9af0e72008-12-26 12:24:24 +090023#else /* CONFIG_GENERIC_HARDIRQS */
Ingo Molnar0ebb26e2008-12-12 11:26:39 +010024
25extern int nr_irqs;
KOSAKI Motohirof9af0e72008-12-26 12:24:24 +090026extern struct irq_desc *irq_to_desc(unsigned int irq);
Ingo Molnar0ebb26e2008-12-12 11:26:39 +010027
KOSAKI Motohirof9af0e72008-12-26 12:24:24 +090028# define for_each_irq_desc(irq, desc) \
29 for (irq = 0, desc = irq_to_desc(irq); irq < nr_irqs; \
KOSAKI Motohiro18eefed2008-12-26 12:29:48 +090030 irq++, desc = irq_to_desc(irq)) \
31 if (desc)
32
33
KOSAKI Motohirof9af0e72008-12-26 12:24:24 +090034# define for_each_irq_desc_reverse(irq, desc) \
35 for (irq = nr_irqs - 1, desc = irq_to_desc(irq); irq >= 0; \
KOSAKI Motohiro18eefed2008-12-26 12:29:48 +090036 irq--, desc = irq_to_desc(irq)) \
37 if (desc)
Yinghai Lu240d3672008-12-08 14:06:17 -080038
KOSAKI Motohirof9af0e72008-12-26 12:24:24 +090039#endif /* CONFIG_GENERIC_HARDIRQS */
Yinghai Lu240d3672008-12-08 14:06:17 -080040
41#define for_each_irq_nr(irq) \
42 for (irq = 0; irq < nr_irqs; irq++)
Thomas Gleixnerdd3a1db2008-10-16 18:20:58 +020043
Ingo Molnar0ebb26e2008-12-12 11:26:39 +010044#endif /* __KERNEL__ */
45
Thomas Gleixnerdd3a1db2008-10-16 18:20:58 +020046#endif