blob: 05aa8c23483ff502bdf94e76365236fa44ff9721 [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);
Thomas Gleixnera98d24b2010-09-30 10:45:07 +020028unsigned int irq_get_next_irq(unsigned int offset);
Ingo Molnar0ebb26e2008-12-12 11:26:39 +010029
KOSAKI Motohirof9af0e72008-12-26 12:24:24 +090030# define for_each_irq_desc(irq, desc) \
31 for (irq = 0, desc = irq_to_desc(irq); irq < nr_irqs; \
KOSAKI Motohiro18eefed2008-12-26 12:29:48 +090032 irq++, desc = irq_to_desc(irq)) \
KOSAKI Motohiro01d07822009-01-04 03:11:05 +090033 if (!desc) \
34 ; \
35 else
KOSAKI Motohiro18eefed2008-12-26 12:29:48 +090036
37
KOSAKI Motohirof9af0e72008-12-26 12:24:24 +090038# define for_each_irq_desc_reverse(irq, desc) \
39 for (irq = nr_irqs - 1, desc = irq_to_desc(irq); irq >= 0; \
KOSAKI Motohiro18eefed2008-12-26 12:29:48 +090040 irq--, desc = irq_to_desc(irq)) \
KOSAKI Motohiro01d07822009-01-04 03:11:05 +090041 if (!desc) \
42 ; \
43 else
Yinghai Lu240d3672008-12-08 14:06:17 -080044
Yinghai Lu5bfb5b52009-08-26 16:20:48 -070045#ifdef CONFIG_SMP
46#define irq_node(irq) (irq_to_desc(irq)->node)
47#else
48#define irq_node(irq) 0
49#endif
50
Thomas Gleixnera98d24b2010-09-30 10:45:07 +020051# define for_each_active_irq(irq) \
52 for (irq = irq_get_next_irq(0); irq < nr_irqs; \
53 irq = irq_get_next_irq(irq + 1))
54
KOSAKI Motohirof9af0e72008-12-26 12:24:24 +090055#endif /* CONFIG_GENERIC_HARDIRQS */
Yinghai Lu240d3672008-12-08 14:06:17 -080056
57#define for_each_irq_nr(irq) \
58 for (irq = 0; irq < nr_irqs; irq++)
Thomas Gleixnerdd3a1db2008-10-16 18:20:58 +020059
Ingo Molnar0ebb26e2008-12-12 11:26:39 +010060#endif /* __KERNEL__ */
61
Thomas Gleixnerdd3a1db2008-10-16 18:20:58 +020062#endif