Skip to content

Commit

Permalink
char: lp: use first unused lp number while registering
Browse files Browse the repository at this point in the history
When the parallel port is usb based and the lp attaches to it based on
LP_PARPORT_AUTO, we do get /dev/lp0 and when we remove the usb device
/dev/lp0 is unregistered. But if we now reconnect the usb device we get
/dev/lp1, another disconnection and reconnection and we get /dev/lp2.

Use the port number array to find the first unused lp number and use
that to register the lp device with the parallel port.

Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
sudipm-mukherjee authored and gregkh committed Dec 19, 2018
1 parent d6318c0 commit dc34da4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/char/lp.c
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,11 @@ static void lp_attach(struct parport *port)
printk(KERN_INFO "lp: ignoring parallel port (max. %d)\n",LP_NO);
return;
}
if (!lp_register(lp_count, port))
for (i = 0; i < LP_NO; i++)
if (port_num[i] == -1)
break;

if (!lp_register(i, port))
lp_count++;
break;

Expand Down

0 comments on commit dc34da4

Please sign in to comment.