blob: fdd5cc16c9c43bcf4bb72cbd7c18d2047af7dd7c [file] [log] [blame]
Thomas Gleixnerdd3a1db2008-10-16 18:20:58 +02001#ifndef _LINUX_IRQNR_H
2#define _LINUX_IRQNR_H
3
David Howells607ca462012-10-13 10:46:48 +01004#include <uapi/linux/irqnr.h>
5
Ingo Molnar0ebb26e2008-12-12 11:26:39 +01006
Ingo Molnar0ebb26e2008-12-12 11:26:39 +01007extern int nr_irqs;
KOSAKI Motohirof9af0e72008-12-26 12:24:24 +09008extern struct irq_desc *irq_to_desc(unsigned int irq);
Thomas Gleixnera98d24b2010-09-30 10:45:07 +02009unsigned int irq_get_next_irq(unsigned int offset);
Ingo Molnar0ebb26e2008-12-12 11:26:39 +010010
KOSAKI Motohirof9af0e72008-12-26 12:24:24 +090011# define for_each_irq_desc(irq, desc) \
12 for (irq = 0, desc = irq_to_desc(irq); irq < nr_irqs; \
KOSAKI Motohiro18eefed2008-12-26 12:29:48 +090013 irq++, desc = irq_to_desc(irq)) \
KOSAKI Motohiro01d07822009-01-04 03:11:05 +090014 if (!desc) \
15 ; \
16 else
KOSAKI Motohiro18eefed2008-12-26 12:29:48 +090017
18
KOSAKI Motohirof9af0e72008-12-26 12:24:24 +090019# define for_each_irq_desc_reverse(irq, desc) \
20 for (irq = nr_irqs - 1, desc = irq_to_desc(irq); irq >= 0; \
KOSAKI Motohiro18eefed2008-12-26 12:29:48 +090021 irq--, desc = irq_to_desc(irq)) \
KOSAKI Motohiro01d07822009-01-04 03:11:05 +090022 if (!desc) \
23 ; \
24 else
Yinghai Lu240d3672008-12-08 14:06:17 -080025
Yinghai Lu5bfb5b52009-08-26 16:20:48 -070026#ifdef CONFIG_SMP
Paul Mundt4600d7c2010-10-28 11:30:31 +090027#define irq_node(irq) (irq_get_irq_data(irq)->node)
Yinghai Lu5bfb5b52009-08-26 16:20:48 -070028#else
29#define irq_node(irq) 0
30#endif
31
Thomas Gleixnera98d24b2010-09-30 10:45:07 +020032# define for_each_active_irq(irq) \
33 for (irq = irq_get_next_irq(0); irq < nr_irqs; \
34 irq = irq_get_next_irq(irq + 1))
35
Yinghai Lu240d3672008-12-08 14:06:17 -080036#define for_each_irq_nr(irq) \
37 for (irq = 0; irq < nr_irqs; irq++)
Thomas Gleixnerdd3a1db2008-10-16 18:20:58 +020038
Thomas Gleixnerdd3a1db2008-10-16 18:20:58 +020039#endif