blob: 3496baa0b07f37929eb68216738a10182257bda5 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Thomas Gleixnerdd3a1db2008-10-16 18:20:58 +02002#ifndef _LINUX_IRQNR_H
3#define _LINUX_IRQNR_H
4
David Howells607ca462012-10-13 10:46:48 +01005#include <uapi/linux/irqnr.h>
6
Ingo Molnar0ebb26e2008-12-12 11:26:39 +01007
Ingo Molnar0ebb26e2008-12-12 11:26:39 +01008extern int nr_irqs;
KOSAKI Motohirof9af0e72008-12-26 12:24:24 +09009extern struct irq_desc *irq_to_desc(unsigned int irq);
Thomas Gleixnera98d24b2010-09-30 10:45:07 +020010unsigned int irq_get_next_irq(unsigned int offset);
Ingo Molnar0ebb26e2008-12-12 11:26:39 +010011
KOSAKI Motohirof9af0e72008-12-26 12:24:24 +090012# define for_each_irq_desc(irq, desc) \
13 for (irq = 0, desc = irq_to_desc(irq); irq < nr_irqs; \
KOSAKI Motohiro18eefed2008-12-26 12:29:48 +090014 irq++, desc = irq_to_desc(irq)) \
KOSAKI Motohiro01d07822009-01-04 03:11:05 +090015 if (!desc) \
16 ; \
17 else
KOSAKI Motohiro18eefed2008-12-26 12:29:48 +090018
19
KOSAKI Motohirof9af0e72008-12-26 12:24:24 +090020# define for_each_irq_desc_reverse(irq, desc) \
21 for (irq = nr_irqs - 1, desc = irq_to_desc(irq); irq >= 0; \
KOSAKI Motohiro18eefed2008-12-26 12:29:48 +090022 irq--, desc = irq_to_desc(irq)) \
KOSAKI Motohiro01d07822009-01-04 03:11:05 +090023 if (!desc) \
24 ; \
25 else
Yinghai Lu240d3672008-12-08 14:06:17 -080026
Thomas Gleixnera98d24b2010-09-30 10:45:07 +020027# define for_each_active_irq(irq) \
28 for (irq = irq_get_next_irq(0); irq < nr_irqs; \
29 irq = irq_get_next_irq(irq + 1))
30
Yinghai Lu240d3672008-12-08 14:06:17 -080031#define for_each_irq_nr(irq) \
32 for (irq = 0; irq < nr_irqs; irq++)
Thomas Gleixnerdd3a1db2008-10-16 18:20:58 +020033
Thomas Gleixnerdd3a1db2008-10-16 18:20:58 +020034#endif