[PARPORT] parport 2.1.85 fix


Andrea Arcangeli (arcangeli@mbox.queen.it)
Wed, 4 Feb 1998 15:12:14 +0100 (CET)


These are my latest diff against 2.1.85 not merged with the official tree.
This patches fix some bugs in parport_procfs and a warining in lp.

If you agree with these patches you can forward them to Linus.

Andrea[s] Arcangeli

--- linux/drivers/char/lp.c 1998/02/04 12:32:29 1.1
+++ linux/drivers/char/lp.c 1998/02/04 12:32:45
@@ -305,6 +305,7 @@
                                         }
                                         current->timeout = jiffies + LP_TIMEOUT_INTERRUPT;
                                         interruptible_sleep_on(&lp->dev->wait_q);
+ disable_irq(lp->dev->port->irq);
                                         w_ctr(minor, LP_PSELECP | LP_PINITP);
                                         sti();
                                         if (lp_check_status(minor))
--- linux/drivers/misc/parport_procfs.c 1998/02/04 12:32:53 1.1
+++ linux/drivers/misc/parport_procfs.c 1998/02/04 13:59:16
@@ -3,6 +3,7 @@
  * Authors: David Campbell <campbell@torque.net>
  * Tim Waugh <tim@cyberelk.demon.co.uk>
  * Philip Blundell <philb@gnu.org>
+ * Andrea Arcangeli <arcangeli@mbox.queen.it>
  *
  * based on work by Grant Guenther <grant@torque.net>
  * and Philip Blundell
@@ -30,7 +31,7 @@
 static int irq_write_proc(struct file *file, const char *buffer,
                                           unsigned long count, void *data)
 {
- int newirq;
+ unsigned int newirq, oldirq;
         struct parport *pp = (struct parport *)data;
         
         if (count > 5 ) /* more than 4 digits + \n for a irq 0x?? 0?? ?? */
@@ -49,32 +50,34 @@
                 }
         }
 
+ if (newirq >= NR_IRQS)
+ return -EOVERFLOW;
+
         if (pp->irq != PARPORT_IRQ_NONE && !(pp->flags & PARPORT_FLAG_COMA)) {
- if (pp->cad->irq_func)
+ if (pp->cad != NULL && pp->cad->irq_func != NULL)
                         free_irq(pp->irq, pp->cad->private);
                 else
                         free_irq(pp->irq, NULL);
         }
 
+ oldirq = pp->irq;
         pp->irq = newirq;
 
         if (pp->irq != PARPORT_IRQ_NONE && !(pp->flags & PARPORT_FLAG_COMA)) {
- struct pardevice *pd = pp->cad;
+ struct pardevice *cad = pp->cad;
 
- if (pd == NULL) {
- pd = pp->devices;
- if (pd != NULL)
- request_irq(pp->irq, pd->irq_func ?
- pd->irq_func :
- parport_null_intr_func,
- SA_INTERRUPT, pd->name,
- pd->private);
- } else {
- request_irq(pp->irq, pd->irq_func ? pd->irq_func :
- parport_null_intr_func,
+ if (cad == NULL)
+ request_irq(pp->irq, parport_null_intr_func
                                     SA_INTERRUPT, pp->name, NULL);
- }
+ else
+ request_irq(pp->irq, cad->irq_func ? cad->irq_func :
+ parport_null_intr_func, SA_INTERRUPT,
+ cad->name, cad->private);
         }
+
+ if (oldirq != PARPORT_IRQ_NONE && newirq == PARPORT_IRQ_NONE &&
+ pp->cad != NULL && pp->cad->irq_func != NULL)
+ pp->cad->irq_func(pp->irq, pp->cad->private, NULL);
 
         return count;
 }

-- 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:24 EST