Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 22 Jun 2009 20:36:22 +0000 (UTC)
From:      Sam Leffler <sam@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r194652 - head/sys/arm/xscale/ixp425
Message-ID:  <200906222036.n5MKaMAZ051857@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sam
Date: Mon Jun 22 20:36:22 2009
New Revision: 194652
URL: http://svn.freebsd.org/changeset/base/194652

Log:
  rewrite arm_get_next_irq to always make forward progress (should be optimized)

Modified:
  head/sys/arm/xscale/ixp425/ixp425.c

Modified: head/sys/arm/xscale/ixp425/ixp425.c
==============================================================================
--- head/sys/arm/xscale/ixp425/ixp425.c	Mon Jun 22 20:34:50 2009	(r194651)
+++ head/sys/arm/xscale/ixp425/ixp425.c	Mon Jun 22 20:36:22 2009	(r194652)
@@ -214,15 +214,27 @@ ixp435_irq_read(void)
 }
 
 int
-arm_get_next_irq(int last __unused)
+arm_get_next_irq(int last)
 {
-	uint32_t irq;
+	uint32_t mask;
 
-	if ((irq = ixp425_irq_read()))
-		return (ffs(irq) - 1);
-	if (cpu_is_ixp43x() && (irq = ixp435_irq_read()))
-		return (32 + ffs(irq) - 1);
-	return (-1);
+	last += 1;		/* always advance fwd, NB: handles -1 */
+	if (last < 32) {
+		mask = ixp425_irq_read() >> last;
+		for (; mask != 0; mask >>= 1, last += 1) {
+			if (mask & 1)
+				return last;
+		}
+		last = 32;
+	}
+	if (cpu_is_ixp43x()) {
+		mask = ixp435_irq_read() >> (32-last);
+		for (; mask != 0; mask >>= 1, last++) {
+			if (mask & 1)
+				return last;
+		}
+	}
+	return -1;
 }
 
 void



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906222036.n5MKaMAZ051857>