2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 #include <linux/init.h>
8 #include <linux/types.h>
10 #include <asm/barrier.h>
12 static DECLARE_BITMAP(irq_map
, NR_IRQS
);
14 int allocate_irqno(void)
19 irq
= find_first_zero_bit(irq_map
, NR_IRQS
);
24 if (test_and_set_bit(irq
, irq_map
))
31 * Allocate the 16 legacy interrupts for i8259 devices. This happens early
32 * in the kernel initialization so treating allocation failure as BUG() is
35 void __init
alloc_legacy_irqno(void)
39 for (i
= 0; i
<= 16; i
++)
40 BUG_ON(test_and_set_bit(i
, irq_map
));
43 void free_irqno(unsigned int irq
)
45 smp_mb__before_atomic();
46 clear_bit(irq
, irq_map
);
47 smp_mb__after_atomic();