[PARPORT] Patch for parport_pc.c to allow for systems without onboard parports but with PCI-card with both serial and parallel ports

From: Erling A. Jacobsen (linuxcub@email.dk)
Date: Thu Nov 27 2003 - 15:06:55 EST

  • Next message: Siva M: "[PARPORT] pg error on loading"

    On systems without integrated parports, but with a PCI-card with serial
    and parallel ports, parport_pc would refuse to load as a module
    (although it is required by parport_serial). However, in order for
    parport_serial to work, parport_pc must be loaded first. The solution
    is, as far as I can see, to allow parport_pc to load even when there is
    no hardware present which parport_pc recognises. That is done by simply
    having init_module() always return 0. This means that cleanup_module()
    may now be called when parport_pc doesn't "own" any devices, in which
    case pci_unregister_driver() shouldn't be called.

    I ran into this on a Red Hat 7.3 system (with the latest kernel), but
    I've just checked the 2.6.0-test10 kernel. It looks like the same could
    happen there.

    A patch is attached (created from a Red Hat 7.3 kernel, but applies to
    2.6.0-test10 as well).

    Erling Jacobsen linuxcub@email.dk

    -- 
    Living in the complex world of the future is somewhat like having bees
    live in your head.  But, there they are.
    

    Patch by Erling Jacobsen <linuxcub@email.dk>

    On systems without integrated parports, parport_pc would refuse to load as a module. However, in order for parport_serial to work, parport_pc must be loaded first. The solution is to allow parport_pc to load even when there is no hardware present which parport_pc recognises. That is done by simply having init_module() always return 0. This means that cleanup_module() may now be called when parport_pc doesn't "own" any devices, in which case pci_unregister_driver() shouldn't be called.

    diff -ur kernel-2.4.20-orig/linux-2.4.20/drivers/parport/parport_pc.c kernel-2.4.20/linux-2.4.20/drivers/parport/parport_pc.c --- kernel-2.4.20-orig/linux-2.4.20/drivers/parport/parport_pc.c Thu Nov 27 16:33:01 2003 +++ kernel-2.4.20/linux-2.4.20/drivers/parport/parport_pc.c Thu Nov 27 16:35:49 2003 @@ -3090,10 +3090,13 @@ } ret = !parport_pc_init (io, io_hi, irqval, dmaval); - if (ret && registered_parport) + if (ret && registered_parport) { pci_unregister_driver (&parport_pc_pci_driver); + registered_parport = 0; + } - return ret; + /* Always return OK, so others (like parport_serial) can use our functions */ + return 0; } void cleanup_module(void) @@ -3101,7 +3104,7 @@ /* We ought to keep track of which ports are actually ours. */ struct parport *p = parport_enumerate(), *tmp; - if (!user_specified) + if (!user_specified && registered_parport) pci_unregister_driver (&parport_pc_pci_driver); while (p) {

    -- 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 2b29 : Thu Nov 27 2003 - 15:14:51 EST