blob: 0a2dc46cdaf6e7070dc602fcde64a23c72553361 [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
Thomas Gleixnerdd3a1db2008-10-16 18:20:58 +02007#ifndef CONFIG_GENERIC_HARDIRQS
8#include <asm/irq.h>
Ingo Molnarbe92d7a2009-01-05 14:34:42 +01009
10/*
11 * Wrappers for non-genirq architectures:
12 */
13#define nr_irqs NR_IRQS
14#define irq_to_desc(irq) (&irq_desc[irq])
Thomas Gleixnerdd3a1db2008-10-16 18:20:58 +020015
16# define for_each_irq_desc(irq, desc) \
17 for (irq = 0; irq < nr_irqs; irq++)
Thomas Gleixnerdd3a1db2008-10-16 18:20:58 +020018
Yinghai Lu240d3672008-12-08 14:06:17 -080019# define for_each_irq_desc_reverse(irq, desc) \
20 for (irq = nr_irqs - 1; irq >= 0; irq--)
Mike Travis9332fcc2009-01-10 22:24:07 -080021
KOSAKI Motohirof9af0e72008-12-26 12:24:24 +090022#else /* CONFIG_GENERIC_HARDIRQS */
Ingo Molnar0ebb26e2008-12-12 11:26:39 +010023
24extern int nr_irqs;
KOSAKI Motohirof9af0e72008-12-26 12:24:24 +090025extern struct irq_desc *irq_to_desc(unsigned int irq);
Thomas Gleixnera98d24b2010-09-30 10:45:07 +020026unsigned int irq_get_next_irq(unsigned int offset);
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)) \
KOSAKI Motohiro01d07822009-01-04 03:11:05 +090031 if (!desc) \
32 ; \
33 else
KOSAKI Motohiro18eefed2008-12-26 12:29:48 +090034
35
KOSAKI Motohirof9af0e72008-12-26 12:24:24 +090036# define for_each_irq_desc_reverse(irq, desc) \
37 for (irq = nr_irqs - 1, desc = irq_to_desc(irq); irq >= 0; \
KOSAKI Motohiro18eefed2008-12-26 12:29:48 +090038 irq--, desc = irq_to_desc(irq)) \
KOSAKI Motohiro01d07822009-01-04 03:11:05 +090039 if (!desc) \
40 ; \
41 else
Yinghai Lu240d3672008-12-08 14:06:17 -080042
Yinghai Lu5bfb5b52009-08-26 16:20:48 -070043#ifdef CONFIG_SMP
Paul Mundt4600d7c2010-10-28 11:30:31 +090044#define irq_node(irq) (irq_get_irq_data(irq)->node)
Yinghai Lu5bfb5b52009-08-26 16:20:48 -070045#else
46#define irq_node(irq) 0
47#endif
48
Thomas Gleixnera98d24b2010-09-30 10:45:07 +020049# define for_each_active_irq(irq) \
50 for (irq = irq_get_next_irq(0); irq < nr_irqs; \
51 irq = irq_get_next_irq(irq + 1))
52
KOSAKI Motohirof9af0e72008-12-26 12:24:24 +090053#endif /* CONFIG_GENERIC_HARDIRQS */
Yinghai Lu240d3672008-12-08 14:06:17 -080054
55#define for_each_irq_nr(irq) \
56 for (irq = 0; irq < nr_irqs; irq++)
Thomas Gleixnerdd3a1db2008-10-16 18:20:58 +020057
Thomas Gleixnerdd3a1db2008-10-16 18:20:58 +020058#endif