Tue May 20 15:03:24 UTC 2014

```Author: hselasky
Date: Tue May 20 15:03:23 2014
New Revision: 266470
URL: http://svnweb.freebsd.org/changeset/base/266470

Log:
Optimise reading of pending interrupt registers. If there are no
pending interrupt bits, skip the bit iteration loop.

Reviewed by:	ian @

Modified:

==============================================================================
@@ -60,6 +60,7 @@ __FBSDID("\$FreeBSD\$");
#define	BANK1_END	(BANK1_START + 32 - 1)
#define	BANK2_START	(BANK1_START + 32)
#define	BANK2_END	(BANK2_START + 32 - 1)
+#define	BANK3_START	(BANK2_START + 32)

#define	IS_IRQ_BASIC(n)	(((n) >= 0) && ((n) < BANK1_START))
#define	IS_IRQ_BANK1(n)	(((n) >= BANK1_START) && ((n) <= BANK1_END))
@@ -150,29 +151,36 @@ arm_get_next_irq(int last_irq)
/* Sanity check */
if (irq < 0)
irq = 0;
-
+
/* TODO: should we mask last_irq? */
-	while (irq < BANK1_START) {
-		if (pending & (1 << irq))
-			return irq;
-		irq++;
+	if (irq < BANK1_START) {
+		if ((pending & 0xFF) == 0) {
+		} else do {
+			if (pending & (1 << irq))
+				return irq;
+			irq++;
+		} while (irq < BANK1_START);
}
-
-	while (irq < BANK2_START) {
-		if (pending & (1 << IRQ_BANK1(irq)))
-			return irq;
-		irq++;
+	if (irq < BANK2_START) {
+		if (pending == 0) {
+		} else do {
+			if (pending & (1 << IRQ_BANK1(irq)))
+				return irq;
+			irq++;
+		} while (irq < BANK2_START);
}
-
-	while (irq <= BANK2_END) {
-		if (pending & (1 << IRQ_BANK2(irq)))
-			return irq;
-		irq++;
+	if (irq < BANK3_START) {
+		if (pending != 0) do {
+			if (pending & (1 << IRQ_BANK2(irq)))
+				return irq;
+			irq++;
+		} while (irq < BANK3_START);
}
-
return (-1);
}

```