[PARPORT] Re: parport irq handling v2


Philip Blundell (philb@gnu.org)
Mon, 31 Aug 1998 16:36:41 +0100


Here's a quick patch to show how I'd like this to be done. It won't actually
build at the moment because parport_procfs needs to be taught how to change
the irq for a port, but it should give you the idea. As you can see it
deletes a lot more code than it adds which can only be a good thing. :-)

p.

--- clean/linux/include/linux/parport.h Wed Aug 12 20:11:27 1998
+++ linux/include/linux/parport.h Mon Aug 31 16:28:37 1998
@@ -123,7 +123,6 @@
 
         void (*enable_irq)(struct parport *);
         void (*disable_irq)(struct parport *);
- int (*examine_irq)(struct parport *);
 
         void (*inc_use_count)(void);
         void (*dec_use_count)(void);
--- clean/linux/drivers/misc/parport_share.c Wed Aug 12 20:11:09 1998
+++ linux/drivers/misc/parport_share.c Mon Aug 31 16:29:52 1998
@@ -55,12 +55,6 @@
         return portlist;
 }
 
-void parport_null_intr_func(int irq, void *dev_id, struct pt_regs *regs)
-{
- /* Null function - does nothing. IRQs are pointed here whenever
- there is no real handler for them. */
-}
-
 struct parport *parport_register_port(unsigned long base, int irq, int dma,
                                       struct parport_operations *ops)
 {
@@ -355,20 +349,6 @@
         port->cad = dev;
         spin_unlock_irqrestore(&port->lock, flags);
 
- /* Swap the IRQ handlers. */
- if (port->irq != PARPORT_IRQ_NONE) {
- if (oldcad && oldcad->irq_func) {
- free_irq(port->irq, oldcad->private);
- request_irq(port->irq, parport_null_intr_func,
- SA_INTERRUPT, port->name, NULL);
- }
- if (dev->irq_func) {
- free_irq(port->irq, NULL);
- request_irq(port->irq, dev->irq_func,
- SA_INTERRUPT, dev->name, dev->private);
- }
- }
-
         /* Restore control registers */
         port->ops->restore_state(port, dev->state);
         dev->time = jiffies;
@@ -457,13 +437,6 @@
 
         /* Save control registers */
         port->ops->save_state(port, dev->state);
-
- /* Point IRQs somewhere harmless. */
- if (port->irq != PARPORT_IRQ_NONE && dev->irq_func) {
- free_irq(port->irq, dev->private);
- request_irq(port->irq, parport_null_intr_func,
- SA_INTERRUPT, port->name, NULL);
- }
 
         /* If anybody is waiting, find out who's been there longest and
            then wake them up. (Note: no locking required) */
--- /usr/src/linux/drivers/misc/parport_pc.c Wed Aug 12 20:11:09 1998
+++ linux/drivers/misc/parport_pc.c Mon Aug 31 16:31:16 1998
@@ -1,4 +1,4 @@
-/* Low-level parallel-port routines for PC-style hardware.
+/* Low-level parallel-port routines for 8255-based PC-style hardware.
  *
  * Authors: Phil Blundell <Philip.Blundell@pobox.com>
  * Tim Waugh <tim@cyberelk.demon.co.uk>
@@ -32,13 +32,8 @@
  * accomodate this.
  */
 
-#include <linux/stddef.h>
-#include <linux/tasks.h>
-
-#include <asm/ptrace.h>
-#include <asm/io.h>
-
 #include <linux/module.h>
+#include <linux/sched.h>
 #include <linux/delay.h>
 #include <linux/errno.h>
 #include <linux/interrupt.h>
@@ -46,6 +41,8 @@
 #include <linux/kernel.h>
 #include <linux/malloc.h>
 
+#include <asm/io.h>
+
 #include <linux/parport.h>
 #include <linux/parport_pc.h>
 
@@ -53,9 +50,11 @@
    than PARPORT_MAX (in <linux/parport.h>). */
 #define PARPORT_PC_MAX_PORTS 8
 
-static void parport_pc_null_intr_func(int irq, void *dev_id, struct pt_regs *regs)
+static void parport_pc_intr(int irq, void *dev_id, struct pt_regs *regs)
 {
- /* Null function - does nothing */
+ struct parport *p = (struct parport *)dev_id;
+ if (p->cad && p->cad->irq_func)
+ p->cad->irq_func(irq, p->cad->private, regs);
 }
 
 void parport_pc_write_epp(struct parport *p, unsigned char d)
@@ -183,7 +182,7 @@
 {
         int err;
         if (p->irq != PARPORT_IRQ_NONE)
- if ((err = request_irq(p->irq, parport_pc_null_intr_func, 0, p->name, NULL)) != 0) return err;
+ if ((err = request_irq(p->irq, parport_pc_intr, 0, p->name, p)) != 0) return err;
         request_region(p->base, p->size, p->name);
         if (p->modes & PARPORT_MODE_PCECR)
                 request_region(p->base+0x400, 3, p->name);
@@ -242,11 +241,6 @@
         return -ENOSYS; /* FIXME */
 }
 
-int parport_pc_examine_irq(struct parport *p)
-{
- return 0; /* FIXME */
-}
-
 void parport_pc_inc_use_count(void)
 {
 #ifdef MODULE
@@ -313,7 +307,6 @@
 
         parport_pc_enable_irq,
         parport_pc_disable_irq,
- parport_pc_examine_irq,
 
         parport_pc_inc_use_count,
         parport_pc_dec_use_count,
@@ -563,12 +556,12 @@
 static int irq_probe_ECP(struct parport *pb)
 {
         int irqs, i;
-
+
         sti();
         irqs = probe_irq_on();
                 
- parport_pc_write_econtrol(pb, 0x00); /* Reset FIFO */
- parport_pc_write_econtrol(pb, 0xd0); /* TEST FIFO + nErrIntrEn */
+ parport_pc_write_econtrol(pb, 0x00); /* Reset FIFO */
+ parport_pc_write_econtrol(pb, 0xd0); /* TEST FIFO + nErrIntrEn */
 
         /* If Full FIFO sure that WriteIntrThresold is generated */
         for (i=0; i < 1024 && !(parport_pc_read_econtrol(pb) & 0x02) ; i++)

-- 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:18:11 EST