mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/5] char: lp: introduce list to save port number
@ 2018-12-07 14:27 Sudip Mukherjee
  2018-12-07 14:27 ` [PATCH 2/5] char: lp: detach the device when parallel port is removed Sudip Mukherjee
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Sudip Mukherjee @ 2018-12-07 14:27 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Arnd Bergmann; +Cc: linux-kernel, Sudip Mukherjee

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>
---
 drivers/char/lp.c | 4 ++++
 1 file changed, 4 insertions(+)

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 @@
 
 static DEFINE_MUTEX(lp_mutex);
 static struct lp_struct lp_table[LP_NO];
+static int port_num[LP_NO];
 
 static unsigned int lp_count = 0;
 static struct class *lp_class;
@@ -938,6 +939,7 @@ static int lp_register(int nr, struct parport *port)
 			       CONSOLE_LP, port->name);
 	}
 #endif
+	port_num[nr] = port->number;
 
 	return 0;
 }
@@ -1013,6 +1015,7 @@ static int __init lp_init(void)
 		init_waitqueue_head(&lp_table[i].dataq);
 		mutex_init(&lp_table[i].port_mutex);
 		lp_table[i].timeout = 10 * HZ;
+		port_num[i] = -1;
 	}
 
 	if (register_chrdev(LP_MAJOR, "lp", &lp_fops)) {
@@ -1091,6 +1094,7 @@ static void lp_cleanup_module(void)
 	for (offset = 0; offset < LP_NO; offset++) {
 		if (lp_table[offset].dev == NULL)
 			continue;
+		port_num[offset] = -1;
 		parport_unregister_device(lp_table[offset].dev);
 		device_destroy(lp_class, MKDEV(LP_MAJOR, offset));
 	}
-- 
2.11.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-12-07 14:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-07 14:27 [PATCH 1/5] char: lp: introduce list to save port number Sudip Mukherjee
2018-12-07 14:27 ` [PATCH 2/5] char: lp: detach the device when parallel port is removed Sudip Mukherjee
2018-12-07 14:27 ` [PATCH 3/5] char: lp: use first unused lp number while registering Sudip Mukherjee
2018-12-07 14:27 ` [PATCH 4/5] char: lp: properly count the lp devices Sudip Mukherjee
2018-12-07 14:27 ` [PATCH 5/5] char: lp: use new parport device model Sudip Mukherjee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®