/* Acknowledge the IRQ using either the PCI host bridge's interrupt acknowledge feature or poll. How i8259_init() is called determines which is called. It should be noted that polling is broken on some IBM and Motorola PReP boxes so we must use the int-ack feature on them.  */
unsigned int i8259_irq(void)
/* Acknowledge the IRQ using either the PCI host bridge's interrupt acknowledge feature or poll. How i8259_init() is called determines which is called. It should be noted that polling is broken on some IBM and Motorola PReP boxes so we must use the int-ack feature on them.  */
unsigned int i8259_irq(void)
{
	int irq;
	int lock = 0;
	if (pci_intack)
		irq = readb(pci_intack);
	else {
		spin_lock(&i8259_lock);
		lock = 1;
		outb(0x0C, 0x20);
		irq = inb(0x20) & 7;
		if (irq == 2 ) {
			outb(0x0C, 0xA0);
			irq = (inb(0xA0) & 7) + 8;
		}
	}
	if (irq == 7) {
		if (!pci_intack)
			outb(0x0B, 0x20);
		if(~inb(0x20) & 0x80)
			irq = NO_IRQ;
	} else if (irq == 0xff)
		irq = NO_IRQ;
	if (lock)
		spin_unlock(&i8259_lock);
	return irq;
}