Tim Waugh (tim@cyberelk.demon.co.uk)
Wed, 29 Apr 1998 23:09:29 +0100 (BST)
Hi guys,
Here's the patch for parport_procfs.c that I plan to send to Linus. I've
tested that it compiles (I get a warning, but it's wrong), but no more.
The aim is to prevent the interrupt from being changed while a driver has
control of the port.
I expect to be quite busy for the next few days, but if I don't hear any
complaints by Monday I'll send it off.
Tim.
*/
--- /big/linux-2.1.98/drivers/misc/parport_share.c Tue Apr 28 20:02:13 1998
+++ linux/drivers/misc/parport_share.c Wed Apr 29 21:20:53 1998
@@ -308,7 +308,9 @@
}
/* Now we do the change of devices */
+ spin_lock_irqsave(&port->lock, flags);
port->cad = dev;
+ spin_unlock_irqrestore(&port->lock, flags);
/* Swap the IRQ handlers. */
if (port->irq != PARPORT_IRQ_NONE) {
@@ -346,9 +348,8 @@
dev->waitprev = port->waittail;
if (port->waittail)
port->waittail->waitnext = dev;
- else {
- port->waithead = dev->port->waittail = dev;
- }
+ else
+ port->waithead = port->waittail = dev;
}
spin_unlock_irqrestore (&port->lock, flags);
}
--- /big/linux-2.1.98/drivers/misc/parport_procfs.c Tue Apr 28 20:02:13 1998
+++ linux/drivers/misc/parport_procfs.c Wed Apr 29 21:17:38 1998
@@ -37,8 +37,8 @@
int retval = -EINVAL;
int newirq = PARPORT_IRQ_NONE;
struct parport *pp = (struct parport *)data;
- struct pardevice *cad = pp->cad;
int oldirq = pp->irq;
+ unsigned long flags;
/*
* We can have these valid cases:
@@ -73,32 +73,27 @@
if (pp->flags & PARPORT_FLAG_COMA)
goto out_ok;
- if (newirq != PARPORT_IRQ_NONE) {
- void (*handler)(int, void *, struct pt_regs *);
-
- if (cad && cad->irq_func)
- handler = cad->irq_func;
- else
- handler = parport_null_intr_func;
+ retval = -EBUSY;
+ spin_lock_irqsave(&port->lock, flags);
+ if (pp->cad)
+ goto out_unlock;
- retval = request_irq(newirq, handler,
- SA_INTERRUPT,
- cad ? cad->name : pp->name,
- cad ? cad->private : NULL);
+ if (newirq != PARPORT_IRQ_NONE) {
+ retval = request_irq(newirq, parport_null_intr_func,
+ SA_INTERRUPT, pp->name, NULL);
if (retval)
- goto out;
+ goto out_unlock;
else retval = count;
}
- if (oldirq != PARPORT_IRQ_NONE) {
- if (cad && cad->irq_func)
- free_irq(oldirq, cad->private);
- else
- free_irq(oldirq, NULL);
- }
+ if (oldirq != PARPORT_IRQ_NONE)
+ free_irq(oldirq, NULL);
out_ok:
pp->irq = newirq;
+
+out_unlock:
+ spin_unlock_irqrestore (&pp->lock, flags);
out:
return retval;
-- To unsubscribe, send mail to: linux-parport-request@torque.net --
-- with the single word "unsubscribe" in the body of the message. --
This archive was generated by hypermail 2.0b3 on Wed 30 Dec 1998 - 10:17:41 EST