diff options
author | Sudip Mukherjee <sudipm.mukherjee@gmail.com> | 2018-12-07 09:27:32 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-12-19 04:40:17 -0500 |
commit | dc34da42860d8ce01f64ac11752eecccf53c1a6c (patch) | |
tree | ae637d8c0a26d8dcac07db45d602c4125bb03203 | |
parent | d6318c0e8318c200aa95b50769d3635907381c08 (diff) |
char: lp: use first unused lp number while registering
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>
-rw-r--r-- | drivers/char/lp.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/char/lp.c b/drivers/char/lp.c index e21ed4007d0f..0e081f521f51 100644 --- a/drivers/char/lp.c +++ b/drivers/char/lp.c | |||
@@ -958,7 +958,11 @@ static void lp_attach(struct parport *port) | |||
958 | printk(KERN_INFO "lp: ignoring parallel port (max. %d)\n",LP_NO); | 958 | printk(KERN_INFO "lp: ignoring parallel port (max. %d)\n",LP_NO); |
959 | return; | 959 | return; |
960 | } | 960 | } |
961 | if (!lp_register(lp_count, port)) | 961 | for (i = 0; i < LP_NO; i++) |
962 | if (port_num[i] == -1) | ||
963 | break; | ||
964 | |||
965 | if (!lp_register(i, port)) | ||
962 | lp_count++; | 966 | lp_count++; |
963 | break; | 967 | break; |
964 | 968 | ||