Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / arch / mips / sgi-ip27 / ip27-irqno.c
blob957ab58e1c007d4687b2bd62995af94d438fd168
1 /*
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
4 * for more details.
5 */
6 #include <linux/init.h>
7 #include <linux/irq.h>
8 #include <linux/types.h>
10 #include <asm/barrier.h>
12 static DECLARE_BITMAP(irq_map, NR_IRQS);
14 int allocate_irqno(void)
16 int irq;
18 again:
19 irq = find_first_zero_bit(irq_map, NR_IRQS);
21 if (irq >= NR_IRQS)
22 return -ENOSPC;
24 if (test_and_set_bit(irq, irq_map))
25 goto again;
27 return irq;
31 * Allocate the 16 legacy interrupts for i8259 devices. This happens early
32 * in the kernel initialization so treating allocation failure as BUG() is
33 * ok.
35 void __init alloc_legacy_irqno(void)
37 int i;
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();