···2626#include <asm/system.h>2727#include <asm/uaccess.h>28282929+static unsigned long irq_map[NR_IRQS / BITS_PER_LONG];3030+3131+int __devinit allocate_irqno(void)3232+{3333+ int irq;3434+3535+again:3636+ irq = find_first_zero_bit(irq_map, NR_IRQS);3737+3838+ if (irq >= NR_IRQS)3939+ return -ENOSPC;4040+4141+ if (test_and_set_bit(irq, irq_map))4242+ goto again;4343+4444+ return irq;4545+}4646+4747+EXPORT_SYMBOL_GPL(allocate_irqno);4848+4949+/*5050+ * Allocate the 16 legacy interrupts for i8259 devices. This happens early5151+ * in the kernel initialization so treating allocation failure as BUG() is5252+ * ok.5353+ */5454+void __init alloc_legacy_irqno(void)5555+{5656+ int i;5757+5858+ for (i = 0; i <= 16; i++)5959+ BUG_ON(test_and_set_bit(i, irq_map));6060+}6161+6262+void __devinit free_irqno(unsigned int irq)6363+{6464+ smp_mb__before_clear_bit();6565+ clear_bit(irq, irq_map);6666+ smp_mb__after_clear_bit();6767+}6868+6969+EXPORT_SYMBOL_GPL(free_irqno);7070+2971/*3072 * 'what should we do if we get a hw irq event on an illegal vector'.3173 * each architecture has to answer this themselves.
-23
arch/mips/sgi-ip27/ip27-irq.c
···354354 .end = end_bridge_irq,355355};356356357357-static unsigned long irq_map[NR_IRQS / BITS_PER_LONG];358358-359359-int allocate_irqno(void)360360-{361361- int irq;362362-363363-again:364364- irq = find_first_zero_bit(irq_map, NR_IRQS);365365-366366- if (irq >= NR_IRQS)367367- return -ENOSPC;368368-369369- if (test_and_set_bit(irq, irq_map))370370- goto again;371371-372372- return irq;373373-}374374-375375-void free_irqno(unsigned int irq)376376-{377377- clear_bit(irq, irq_map);378378-}379379-380357void __devinit register_bridge_irq(unsigned int irq)381358{382359 irq_desc[irq].status = IRQ_DISABLED;
-2
arch/mips/sgi-ip27/ip27-timer.c
···214214 .name = "timer"215215};216216217217-extern int allocate_irqno(void);218218-219217void __init plat_timer_setup(struct irqaction *irq)220218{221219 int irqno = allocate_irqno();
+4
include/asm-mips/irq.h
···7474 unsigned long hwmask);7575#endif /* CONFIG_MIPS_MT_SMTC */76767777+extern int allocate_irqno(void);7878+extern void alloc_legacy_irqno(void);7979+extern void free_irqno(unsigned int irq);8080+7781#endif /* _ASM_IRQ_H */