blob: 7bf89bc8cbca32762d082664c1839d8d642f8782 [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--)
Mike Travis9332fcc2009-01-10 22:24:07 -080023
KOSAKI Motohirof9af0e72008-12-26 12:24:24 +090024#else /* CONFIG_GENERIC_HARDIRQS */
Ingo Molnar0ebb26e2008-12-12 11:26:39 +010025
26extern int nr_irqs;
KOSAKI Motohirof9af0e72008-12-26 12:24:24 +090027extern struct irq_desc *irq_to_desc(unsigned int irq);
Ingo Molnar0ebb26e2008-12-12 11:26:39 +010028
KOSAKI Motohirof9af0e72008-12-26 12:24:24 +090029# define for_each_irq_desc(irq, desc) \
30 for (irq = 0, desc = irq_to_desc(irq); irq < nr_irqs; \
KOSAKI Motohiro18eefed2008-12-26 12:29:48 +090031 irq++, desc = irq_to_desc(irq)) \
KOSAKI Motohiro01d07822009-01-04 03:11:05 +090032 if (!desc) \
33 ; \
34 else
KOSAKI Motohiro18eefed2008-12-26 12:29:48 +090035
36
KOSAKI Motohirof9af0e72008-12-26 12:24:24 +090037# define for_each_irq_desc_reverse(irq, desc) \
38 for (irq = nr_irqs - 1, desc = irq_to_desc(irq); irq >= 0; \
KOSAKI Motohiro18eefed2008-12-26 12:29:48 +090039 irq--, desc = irq_to_desc(irq)) \
KOSAKI Motohiro01d07822009-01-04 03:11:05 +090040 if (!desc) \
41 ; \
42 else
Yinghai Lu240d3672008-12-08 14:06:17 -080043
Yinghai Lu5bfb5b52009-08-26 16:20:48 -070044#ifdef CONFIG_SMP
45#define irq_node(irq) (irq_to_desc(irq)->node)
46#else
47#define irq_node(irq) 0
48#endif
49
KOSAKI Motohirof9af0e72008-12-26 12:24:24 +090050#endif /* CONFIG_GENERIC_HARDIRQS */
Yinghai Lu240d3672008-12-08 14:06:17 -080051
52#define for_each_irq_nr(irq) \
53 for (irq = 0; irq < nr_irqs; irq++)
Thomas Gleixnerdd3a1db2008-10-16 18:20:58 +020054
Ingo Molnar0ebb26e2008-12-12 11:26:39 +010055#endif /* __KERNEL__ */
56
Thomas Gleixnerdd3a1db2008-10-16 18:20:58 +020057#endif