Parport patch

Tim Waugh (tim@cyberelk.demon.co.uk)
Wed, 29 Apr 1998 23:13:53 +0100 (BST)


Hi,

Here is a patch that is meant to prevent the non-fatal oopses that can
occur if someone writes to /proc/parport/0/irq while printing.

Please test it out.

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 from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu