[PARPORT] Parport numbering


Tim Waugh (tim@cyberelk.demon.co.uk)
Sat, 21 Feb 1998 23:34:32 +0000 (GMT)


Hi everyone,

A little while ago there was a discussion on linux-kernel about parport
numbering. The problem was that doing

        # modprobe lp parport=-1,0
        # rmmod lp
        # rmmod parport_lowlevel # but keep parport loaded
        # modprobe lp parport=-1,0

didn't have the desired effect. This is because when lp is loaded the
second time, it causes parport_lowlevel to be reloaded, but the parports
get different numbers.

So, if the first modprobe assigns parport0 to lp1, the second modprobe
only provides a parport1, so lp finds no devices. The reason is the way
parport numbers are never re-used.

I think the original reason for this is that the SCSI people did exactly
the same thing. However, they seem to be changing their collective mind.
I saw a comment on linux-scsi that leads me to this suggestion:

When parport_unregister_port is called for the very last allocated parport
number, that parport number should be available for re-use.

Here's a patch to show you what I mean. What I've missed out is
the change in the lowlevel drivers to unregister their ports in
reverse order to how they registered them.

Comments?

Tim.
*/

--- parport_share.c~ Sat Feb 21 23:29:03 1998
+++ parport_share.c Sat Feb 21 23:31:42 1998
@@ -118,6 +118,9 @@
 void parport_unregister_port(struct parport *port)
 {
         struct parport *p;
+ char lastname[16];
+ sprintf (lastname, "parport%d", portcount - 1);
+ if (!strcmp (port->name, lastname)) portcount--;
         kfree(port->name);
         if (portlist == port) {
                 if ((portlist = port->next) == NULL)

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