diff options
author | Sudip Mukherjee <sudipm.mukherjee@gmail.com> | 2018-12-07 09:27:30 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-12-19 04:40:17 -0500 |
commit | 0edf39d2c7dbb4947358dd102b6ff35eaaa92d68 (patch) | |
tree | 6954ca960b310afe97a645e8a0bef89a5e38d779 | |
parent | 2e79c1874968b8fdbf578a2a364ec9b6263c77ca (diff) |
char: lp: introduce list to save port number
When we are registering lp in LP_PARPORT_AUTO mode, we are not keeping
any record of the parallel port number to which lp is connecting.
Add an array to save the port number to it.
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 | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/char/lp.c b/drivers/char/lp.c index e0a92d764eee..7e207ff0f2fe 100644 --- a/drivers/char/lp.c +++ b/drivers/char/lp.c | |||
@@ -141,6 +141,7 @@ | |||
141 | 141 | ||
142 | static DEFINE_MUTEX(lp_mutex); | 142 | static DEFINE_MUTEX(lp_mutex); |
143 | static struct lp_struct lp_table[LP_NO]; | 143 | static struct lp_struct lp_table[LP_NO]; |
144 | static int port_num[LP_NO]; | ||
144 | 145 | ||
145 | static unsigned int lp_count = 0; | 146 | static unsigned int lp_count = 0; |
146 | static struct class *lp_class; | 147 | static struct class *lp_class; |
@@ -938,6 +939,7 @@ static int lp_register(int nr, struct parport *port) | |||
938 | CONSOLE_LP, port->name); | 939 | CONSOLE_LP, port->name); |
939 | } | 940 | } |
940 | #endif | 941 | #endif |
942 | port_num[nr] = port->number; | ||
941 | 943 | ||
942 | return 0; | 944 | return 0; |
943 | } | 945 | } |
@@ -1013,6 +1015,7 @@ static int __init lp_init(void) | |||
1013 | init_waitqueue_head(&lp_table[i].dataq); | 1015 | init_waitqueue_head(&lp_table[i].dataq); |
1014 | mutex_init(&lp_table[i].port_mutex); | 1016 | mutex_init(&lp_table[i].port_mutex); |
1015 | lp_table[i].timeout = 10 * HZ; | 1017 | lp_table[i].timeout = 10 * HZ; |
1018 | port_num[i] = -1; | ||
1016 | } | 1019 | } |
1017 | 1020 | ||
1018 | if (register_chrdev(LP_MAJOR, "lp", &lp_fops)) { | 1021 | if (register_chrdev(LP_MAJOR, "lp", &lp_fops)) { |
@@ -1091,6 +1094,7 @@ static void lp_cleanup_module(void) | |||
1091 | for (offset = 0; offset < LP_NO; offset++) { | 1094 | for (offset = 0; offset < LP_NO; offset++) { |
1092 | if (lp_table[offset].dev == NULL) | 1095 | if (lp_table[offset].dev == NULL) |
1093 | continue; | 1096 | continue; |
1097 | port_num[offset] = -1; | ||
1094 | parport_unregister_device(lp_table[offset].dev); | 1098 | parport_unregister_device(lp_table[offset].dev); |
1095 | device_destroy(lp_class, MKDEV(LP_MAJOR, offset)); | 1099 | device_destroy(lp_class, MKDEV(LP_MAJOR, offset)); |
1096 | } | 1100 | } |