shithub: riscv

Download patch

ref: 3ab80c9fe0fe4cfe91c0b6004db986f2e72bf5e6
parent: c404fd9d6f46f90e4420d0b268215ef719e25796
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Mon Dec 22 11:56:04 EST 2014

pc, pc64, xen: change return type of intrdisable() to void

intrdisable() will always be able to unregister the interrupt
now, so there is no reason to have it return an error value.

all drivers except uart8250 already assumed it to never fail
and theres no need to maintain that complexity.

--- a/sys/src/9/pc/fns.h
+++ b/sys/src/9/pc/fns.h
@@ -83,7 +83,7 @@
 void	inss(int, void*, int);
 ulong	inl(int);
 void	insl(int, void*, int);
-int	intrdisable(int, void (*)(Ureg *, void *), void*, int, char*);
+void	intrdisable(int, void (*)(Ureg *, void *), void*, int, char*);
 void	intrenable(int, void (*)(Ureg*, void*), void*, int, char*);
 void	introff(void);
 void	intron(void);
--- a/sys/src/9/pc/trap.c
+++ b/sys/src/9/pc/trap.c
@@ -76,7 +76,7 @@
 	iunlock(&vctllock);
 }
 
-int
+void
 intrdisable(int irq, void (*f)(Ureg *, void *), void *a, int tbdf, char *name)
 {
 	Vctl **pv, *v;
@@ -116,7 +116,6 @@
 			break;
 	}
 	iunlock(&vctllock);
-	return 0;
 }
 
 static long
--- a/sys/src/9/pc/uarti8250.c
+++ b/sys/src/9/pc/uarti8250.c
@@ -542,8 +542,8 @@
 	csr8w(ctlr, Ier, ctlr->sticky[Ier]);
 
 	if(ctlr->iena != 0){
-		if(intrdisable(ctlr->irq, i8250interrupt, uart, ctlr->tbdf, uart->name) == 0)
-			ctlr->iena = 0;
+		ctlr->iena = 0;
+		intrdisable(ctlr->irq, i8250interrupt, uart, ctlr->tbdf, uart->name);
 	}
 }
 
--- a/sys/src/9/pc64/fns.h
+++ b/sys/src/9/pc64/fns.h
@@ -74,7 +74,7 @@
 void	inss(int, void*, int);
 ulong	inl(int);
 void	insl(int, void*, int);
-int	intrdisable(int, void (*)(Ureg *, void *), void*, int, char*);
+void	intrdisable(int, void (*)(Ureg *, void *), void*, int, char*);
 void	intrenable(int, void (*)(Ureg*, void*), void*, int, char*);
 void	introff(void);
 void	intron(void);
--- a/sys/src/9/pc64/trap.c
+++ b/sys/src/9/pc64/trap.c
@@ -76,7 +76,7 @@
 	iunlock(&vctllock);
 }
 
-int
+void
 intrdisable(int irq, void (*f)(Ureg *, void *), void *a, int tbdf, char *name)
 {
 	Vctl **pv, *v;
@@ -116,7 +116,6 @@
 			break;
 	}
 	iunlock(&vctllock);
-	return 0;
 }
 
 static long
--- a/sys/src/9/xen/fns.h
+++ b/sys/src/9/xen/fns.h
@@ -54,7 +54,7 @@
 void	inss(int, void*, int);
 ulong	inl(int);
 void	insl(int, void*, int);
-int	intrdisable(int, void (*)(Ureg *, void *), void*, int, char*);
+void	intrdisable(int, void (*)(Ureg *, void *), void*, int, char*);
 void	intrenable(int, void (*)(Ureg*, void*), void*, int, char*);
 int	ioalloc(int, int, int, char*);
 void	ioinit(void);
--- a/sys/src/9/xen/trap.c
+++ b/sys/src/9/xen/trap.c
@@ -90,36 +90,27 @@
 	iunlock(&vctllock);
 }
 
-int
+void
 intrdisable(int irq, void (*f)(Ureg *, void *), void *a, int tbdf, char *name)
 {
 	Vctl **pv, *v;
 	int vno;
 
-	/*
-	 * For now, none of this will work with the APIC code,
-	 * there is no mapping between irq and vector as the IRQ
-	 * is pretty meaningless.
-	 */
-	if(arch->intrvecno == nil)
-		return -1;
 	vno = arch->intrvecno(irq);
 	ilock(&vctllock);
-	pv = &vctl[vno];
-	while (*pv && 
-		  ((*pv)->irq != irq || (*pv)->tbdf != tbdf || (*pv)->f != f || (*pv)->a != a ||
-		   strcmp((*pv)->name, name)))
-		pv = &((*pv)->next);
-	assert(*pv);
+	for(pv = &vctl[vno]; (v = *pv) != nil; pv = &v->next){
+		if(v->isintr && v->irq == irq
+		&& v->tbdf == tbdf && v->f == f && v->a == a
+		&& strcmp(v->name, name) == 0){
+			*pv = v->next;
+			xfree(v);
 
-	v = *pv;
-	*pv = (*pv)->next;	/* Link out the entry */
-	
-	if(vctl[vno] == nil && arch->intrdisable != nil)
-		arch->intrdisable(irq);
+			if(vctl[vno] == nil && arch->intrdisable != nil)
+				arch->intrdisable(irq);
+			break;
+		}
+	}
 	iunlock(&vctllock);
-	xfree(v);
-	return 0;
 }
 
 static long