[PARPORT] Patch against 980105


Tim Waugh (tim@cyberelk.demon.co.uk)
Sat, 10 Jan 1998 16:02:29 +0000 (GMT)


This fixes the problem I reported just now. parport_release was offering
every registered device a wakeup -- including the device that just
released...

Also, I've taken out the wakeup function in parport_probe, seeing as it
isn't actually needed.

I've moved MOD_{INC,DEC}_USE_COUNT into parport_probe_one, because
otherwise the probe only appears to be in use when it's initializing and
not when called from the hook. Is that right?

Tim.
*/

--- linux/drivers/pnp/parport_probe.c.orig Sat Jan 10 15:56:27 1998
+++ linux/drivers/pnp/parport_probe.c Sat Jan 10 15:44:18 1998
@@ -83,21 +83,9 @@
         return count;
 }
 
-static struct wait_queue *wait_q;
-
-static void wakeup(void *ref)
-{
- struct pardevice **dev = (struct pardevice **)ref;
-
- if (!waitqueue_active || parport_claim(*dev))
- return;
-
- wake_up(&wait_q);
-}
-
 int parport_probe(struct parport *port, char *buffer, int len)
 {
- struct pardevice *dev = parport_register_device(port, "IEEE 1284 probe", NULL, wakeup, NULL, PARPORT_DEV_TRAN, &dev);
+ struct pardevice *dev = parport_register_device(port, "IEEE 1284 probe", NULL, NULL, NULL, PARPORT_DEV_TRAN, &dev);
 
         int result = 0;
 
@@ -106,9 +94,7 @@
                 return -EINVAL;
         }
 
- init_waitqueue (&wait_q);
- if (parport_claim(dev))
- sleep_on(&wait_q);
+ parport_claim_or_block(dev);
 
         switch (parport_ieee1284_nibble_mode_ok(port, 4)) {
         case 1:
@@ -233,6 +219,7 @@
         char *buffer = kmalloc(2048, GFP_KERNEL);
         int r;
 
+ MOD_INC_USE_COUNT;
         port->probe_info.model = "Unknown device";
         port->probe_info.mfr = "Unknown vendor";
         port->probe_info.description = NULL;
@@ -261,17 +248,16 @@
                 pretty_print(port);
         }
         kfree(buffer);
+ MOD_DEC_USE_COUNT;
 }
 
 #if MODULE
 int init_module(void)
 {
         struct parport *p;
- MOD_INC_USE_COUNT;
         for (p = parport_enumerate(); p; p = p->next)
                 parport_probe_one(p);
         parport_probe_hook = &parport_probe_one;
- MOD_DEC_USE_COUNT;
         return 0;
 }
 
--- linux/drivers/misc/parport_share.c.orig Sat Jan 10 15:57:50 1998
+++ linux/drivers/misc/parport_share.c Sat Jan 10 15:57:58 1998
@@ -427,7 +427,7 @@
         /* Nobody was waiting, so walk the list to see if anyone is
            interested in being woken up. */
         for (pd = port->devices; (port->cad == NULL) && pd; pd = pd->next) {
- if (pd->wakeup)
+ if (pd->wakeup && pd != dev)
                         pd->wakeup(pd->private);
         }
 }

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