shithub: riscv

Download patch

ref: c6069e28ac0e5a66000f0a887367d7c68410e253
parent: 173bafd8007ed844eb59ae5882427b0a5a5b98a9
author: cinap_lenrek <[email protected]>
date: Fri Feb 20 13:43:32 EST 2015

pc, pc64: simplify intrdisable()

--- a/sys/src/9/pc/trap.c
+++ b/sys/src/9/pc/trap.c
@@ -96,7 +96,7 @@
 		vno = arch->intrvecno(irq);
 	}
 	ilock(&vctllock);
-	for(; vno <= MaxVectorAPIC; vno++){
+	do {
 		for(pv = &vctl[vno]; (v = *pv) != nil; pv = &v->next){
 			if(v->isintr && (v->irq == irq || irq == -1)
 			&& v->tbdf == tbdf && v->f == f && v->a == a
@@ -107,14 +107,11 @@
 			*pv = v->next;
 			xfree(v);
 
-			if(irq == -1)
-				break;
-			if(vctl[vno] == nil && arch->intrdisable != nil)
+			if(irq != -1 && vctl[vno] == nil && arch->intrdisable != nil)
 				arch->intrdisable(irq);
-		}
-		if(irq != -1)
 			break;
-	}
+		}
+	} while(irq == -1 && ++vno <= MaxVectorAPIC);
 	iunlock(&vctllock);
 }
 
--- a/sys/src/9/pc64/trap.c
+++ b/sys/src/9/pc64/trap.c
@@ -96,7 +96,7 @@
 		vno = arch->intrvecno(irq);
 	}
 	ilock(&vctllock);
-	for(; vno <= MaxVectorAPIC; vno++){
+	do {
 		for(pv = &vctl[vno]; (v = *pv) != nil; pv = &v->next){
 			if(v->isintr && (v->irq == irq || irq == -1)
 			&& v->tbdf == tbdf && v->f == f && v->a == a
@@ -107,14 +107,11 @@
 			*pv = v->next;
 			xfree(v);
 
-			if(irq == -1)
-				break;
-			if(vctl[vno] == nil && arch->intrdisable != nil)
+			if(irq != -1 && vctl[vno] == nil && arch->intrdisable != nil)
 				arch->intrdisable(irq);
-		}
-		if(irq != -1)
 			break;
-	}
+		}
+	} while(irq == -1 && ++vno <= MaxVectorAPIC);
 	iunlock(&vctllock);
 }