mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/5] Char: rocket, fix dynamic_dev tty
@ 2007-10-15 16:29 Jiri Slaby
  2007-10-15 16:29 ` [PATCH 2/5] Char: rocket, don't re-set statics to 0 Jiri Slaby
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Jiri Slaby @ 2007-10-15 16:29 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

rocket, fix dynamic_dev tty

- register_device unconditionally (non-pci dependent) to have also isa
  devices in /dev
- unregister devices on module removal
- don't set TTY_DRIVER_DYNAMIC_DEV twice (removed the one dependent on some
  macro)

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Cc: Ferenc Wagner <wferi@niif.hu>

---
commit afb1b8bbdc2cc13a8c2c7d9fff49a3098a370971
tree 49f12cbadea0b74968a7626301028fb0ccb31209
parent 4b741d759e5b898bf1bf19631d5e5b14a221ce52
author Jiri Slaby <jirislaby@gmail.com> Mon, 15 Oct 2007 13:32:44 +0200
committer Jiri Slaby <jirislaby@gmail.com> Mon, 15 Oct 2007 13:32:44 +0200

 drivers/char/rocket.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c
index 56cbba7..94bb3d0 100644
--- a/drivers/char/rocket.c
+++ b/drivers/char/rocket.c
@@ -699,8 +699,8 @@ static void init_r_port(int board, int aiop, int chan, struct pci_dev *pci_dev)
 	spin_lock_init(&info->slock);
 	mutex_init(&info->write_mtx);
 	rp_table[line] = info;
-	if (pci_dev)
-		tty_register_device(rocket_driver, line, &pci_dev->dev);
+	tty_register_device(rocket_driver, line, pci_dev ? &pci_dev->dev :
+			NULL);
 }
 
 /*
@@ -2434,7 +2434,7 @@ static int __init rp_init(void)
 	rocket_driver->init_termios.c_ispeed = 9600;
 	rocket_driver->init_termios.c_ospeed = 9600;
 #ifdef ROCKET_SOFT_FLOW
-	rocket_driver->flags |= TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
+	rocket_driver->flags |= TTY_DRIVER_REAL_RAW;
 #endif
 	tty_set_operations(rocket_driver, &rocket_ops);
 
@@ -2491,10 +2491,14 @@ static void rp_cleanup_module(void)
 	if (retval)
 		printk(KERN_INFO "Error %d while trying to unregister "
 		       "rocketport driver\n", -retval);
-	put_tty_driver(rocket_driver);
 
 	for (i = 0; i < MAX_RP_PORTS; i++)
-		kfree(rp_table[i]);
+		if (rp_table[i]) {
+			tty_unregister_device(rocket_driver, i);
+			kfree(rp_table[i]);
+		}
+
+	put_tty_driver(rocket_driver);
 
 	for (i = 0; i < NUM_BOARDS; i++) {
 		if (rcktpt_io_addr[i] <= 0 || is_PCI[i])

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

* [PATCH 2/5] Char: rocket, don't re-set statics to 0
  2007-10-15 16:29 [PATCH 1/5] Char: rocket, fix dynamic_dev tty Jiri Slaby
@ 2007-10-15 16:29 ` Jiri Slaby
  2007-10-15 16:30 ` [PATCH 3/5] Char: rocket, remove pci_read_config_dword(CLASS_REVISION) Jiri Slaby
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Jiri Slaby @ 2007-10-15 16:29 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

rocket, don't re-set statics to 0

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>

---
commit ad37fddef12ce908078883fdc27297216c6d122e
tree bf07d0f19abdc4220b1888e5385023c936fe3028
parent afb1b8bbdc2cc13a8c2c7d9fff49a3098a370971
author Jiri Slaby <jirislaby@gmail.com> Mon, 15 Oct 2007 13:53:01 +0200
committer Jiri Slaby <jirislaby@gmail.com> Mon, 15 Oct 2007 13:53:01 +0200

 drivers/char/rocket.c |   12 ------------
 1 files changed, 0 insertions(+), 12 deletions(-)

diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c
index 94bb3d0..5fd1ed7 100644
--- a/drivers/char/rocket.c
+++ b/drivers/char/rocket.c
@@ -2372,18 +2372,6 @@ static int __init rp_init(void)
 		return -ENOMEM;
 
 	/*
-	 * Initialize the array of pointers to our own internal state
-	 * structures.
-	 */
-	memset(rp_table, 0, sizeof (rp_table));
-	memset(xmit_flags, 0, sizeof (xmit_flags));
-
-	for (i = 0; i < MAX_RP_PORTS; i++)
-		lineNumbers[i] = 0;
-	nextLineNumber = 0;
-	memset(rocketModel, 0, sizeof (rocketModel));
-
-	/*
 	 *  If board 1 is non-zero, there is at least one ISA configured.  If controller is 
 	 *  zero, use the default controller IO address of board1 + 0x40.
 	 */

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

* [PATCH 3/5] Char: rocket, remove pci_read_config_dword(CLASS_REVISION)
  2007-10-15 16:29 [PATCH 1/5] Char: rocket, fix dynamic_dev tty Jiri Slaby
  2007-10-15 16:29 ` [PATCH 2/5] Char: rocket, don't re-set statics to 0 Jiri Slaby
@ 2007-10-15 16:30 ` Jiri Slaby
  2007-10-15 16:31 ` [PATCH 4/5] Char: rocket, remove potential leak in module_init Jiri Slaby
  2007-10-15 16:31 ` [PATCH 5/5] Char: rocket, fix signed/unsigned warning Jiri Slaby
  3 siblings, 0 replies; 5+ messages in thread
From: Jiri Slaby @ 2007-10-15 16:30 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

rocket, remove pci_read_config_dword(CLASS_REVISION)

We may use pdev->revision instead of reading pci config space directly, so
remove pci_read_config_dword invoking.

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>

---
commit 2b2c0385d705ce1f4207595f8fda12c25ee39de3
tree 2c09638bcb6ee3f671dd3038c21efeb2b958e6dc
parent ad37fddef12ce908078883fdc27297216c6d122e
author Jiri Slaby <jirislaby@gmail.com> Mon, 15 Oct 2007 14:42:18 +0200
committer Jiri Slaby <jirislaby@gmail.com> Mon, 15 Oct 2007 14:42:18 +0200

 drivers/char/rocket.c |   15 ++++-----------
 1 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c
index 5fd1ed7..e4bcfa2 100644
--- a/drivers/char/rocket.c
+++ b/drivers/char/rocket.c
@@ -1869,8 +1869,6 @@ static __init int register_PCI(int i, struct pci_dev *dev)
 	int fast_clock = 0;
 	int altChanRingIndicator = 0;
 	int ports_per_aiop = 8;
-	int ret;
-	unsigned int class_rev;
 	WordIO_t ConfigIO = 0;
 	ByteIO_t UPCIRingInd = 0;
 
@@ -1878,12 +1876,6 @@ static __init int register_PCI(int i, struct pci_dev *dev)
 		return 0;
 
 	rcktpt_io_addr[i] = pci_resource_start(dev, 0);
-	ret = pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
-
-	if (ret) {
-		printk(KERN_INFO "  Error during register_PCI(), unable to read config dword \n");
-		return 0;
-	}
 
 	rcktpt_type[i] = ROCKET_TYPE_NORMAL;
 	rocketModel[i].loadrm2 = 0;
@@ -2037,8 +2029,9 @@ static __init int register_PCI(int i, struct pci_dev *dev)
 		ports_per_aiop = 6;
 		str = "6-port";
 
-		/*  If class_rev is 1, the rocketmodem flash must be loaded.  If it is 2 it is a "socketed" version. */
-		if ((class_rev & 0xFF) == 1) {
+		/*  If revision is 1, the rocketmodem flash must be loaded.
+		 *  If it is 2 it is a "socketed" version. */
+		if (dev->revision == 1) {
 			rcktpt_type[i] = ROCKET_TYPE_MODEMII;
 			rocketModel[i].loadrm2 = 1;
 		} else {
@@ -2053,7 +2046,7 @@ static __init int register_PCI(int i, struct pci_dev *dev)
 		max_num_aiops = 1;
 		ports_per_aiop = 4;
 		str = "4-port";
-		if ((class_rev & 0xFF) == 1) {
+		if (dev->revision == 1) {
 			rcktpt_type[i] = ROCKET_TYPE_MODEMII;
 			rocketModel[i].loadrm2 = 1;
 		} else {

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

* [PATCH 4/5] Char: rocket, remove potential leak in module_init
  2007-10-15 16:29 [PATCH 1/5] Char: rocket, fix dynamic_dev tty Jiri Slaby
  2007-10-15 16:29 ` [PATCH 2/5] Char: rocket, don't re-set statics to 0 Jiri Slaby
  2007-10-15 16:30 ` [PATCH 3/5] Char: rocket, remove pci_read_config_dword(CLASS_REVISION) Jiri Slaby
@ 2007-10-15 16:31 ` Jiri Slaby
  2007-10-15 16:31 ` [PATCH 5/5] Char: rocket, fix signed/unsigned warning Jiri Slaby
  3 siblings, 0 replies; 5+ messages in thread
From: Jiri Slaby @ 2007-10-15 16:31 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

rocket, remove potential leak in module_init

if (controller && !request_region) then we leaked a tty driver struct,
fix it by adding function deinit tail with goto-ing into it (and from other
fail paths too)

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>

---
commit 8aa70f167a6ae0f80af0d73a5365c81f2e146709
tree 3f44eb6baabbf501738c857b6114010ac408108e
parent 2b2c0385d705ce1f4207595f8fda12c25ee39de3
author Jiri Slaby <jirislaby@gmail.com> Mon, 15 Oct 2007 15:13:01 +0200
committer Jiri Slaby <jirislaby@gmail.com> Mon, 15 Oct 2007 15:13:01 +0200

 drivers/char/rocket.c |   34 ++++++++++++++++++++--------------
 1 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c
index e4bcfa2..27bb0cd 100644
--- a/drivers/char/rocket.c
+++ b/drivers/char/rocket.c
@@ -2355,14 +2355,14 @@ static const struct tty_operations rocket_ops = {
  */
 static int __init rp_init(void)
 {
-	int retval, pci_boards_found, isa_boards_found, i;
+	int ret = -ENOMEM, pci_boards_found, isa_boards_found, i;
 
 	printk(KERN_INFO "RocketPort device driver module, version %s, %s\n",
 	       ROCKET_VERSION, ROCKET_DATE);
 
 	rocket_driver = alloc_tty_driver(MAX_RP_PORTS);
 	if (!rocket_driver)
-		return -ENOMEM;
+		goto err;
 
 	/*
 	 *  If board 1 is non-zero, there is at least one ISA configured.  If controller is 
@@ -2377,8 +2377,11 @@ static int __init rp_init(void)
 
 	/*  If an ISA card is configured, reserve the 4 byte IO space for the Mudbac controller */
 	if (controller && (!request_region(controller, 4, "Comtrol RocketPort"))) {
-		printk(KERN_INFO "Unable to reserve IO region for first configured ISA RocketPort controller 0x%lx.  Driver exiting \n", controller);
-		return -EBUSY;
+		printk(KERN_ERR "Unable to reserve IO region for first "
+			"configured ISA RocketPort controller 0x%lx.  "
+			"Driver exiting\n", controller);
+		ret = -EBUSY;
+		goto err_tty;
 	}
 
 	/*  Store ISA variable retrieved from command line or .conf file. */
@@ -2419,11 +2422,10 @@ static int __init rp_init(void)
 #endif
 	tty_set_operations(rocket_driver, &rocket_ops);
 
-	retval = tty_register_driver(rocket_driver);
-	if (retval < 0) {
-		printk(KERN_INFO "Couldn't install tty RocketPort driver (error %d)\n", -retval);
-		put_tty_driver(rocket_driver);
-		return -1;
+	ret = tty_register_driver(rocket_driver);
+	if (ret < 0) {
+		printk(KERN_ERR "Couldn't install tty RocketPort driver\n");
+		goto err_tty;
 	}
 
 #ifdef ROCKET_DEBUG_OPEN
@@ -2450,14 +2452,18 @@ static int __init rp_init(void)
 	max_board = pci_boards_found + isa_boards_found;
 
 	if (max_board == 0) {
-		printk(KERN_INFO "No rocketport ports found; unloading driver.\n");
-		del_timer_sync(&rocket_timer);
-		tty_unregister_driver(rocket_driver);
-		put_tty_driver(rocket_driver);
-		return -ENXIO;
+		printk(KERN_ERR "No rocketport ports found; unloading driver\n");
+		ret = -ENXIO;
+		goto err_ttyu;
 	}
 
 	return 0;
+err_ttyu:
+	tty_unregister_driver(rocket_driver);
+err_tty:
+	put_tty_driver(rocket_driver);
+err:
+	return ret;
 }
 
 

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

* [PATCH 5/5] Char: rocket, fix signed/unsigned warning
  2007-10-15 16:29 [PATCH 1/5] Char: rocket, fix dynamic_dev tty Jiri Slaby
                   ` (2 preceding siblings ...)
  2007-10-15 16:31 ` [PATCH 4/5] Char: rocket, remove potential leak in module_init Jiri Slaby
@ 2007-10-15 16:31 ` Jiri Slaby
  3 siblings, 0 replies; 5+ messages in thread
From: Jiri Slaby @ 2007-10-15 16:31 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

rocket, fix signed/unsigned warning

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>

---
commit 5c008a5651ee92ebe020dd5108a66a7db74fe41d
tree 644fcf0e18b8fbf06d70014c95acd7cfc7b5dfa6
parent 8aa70f167a6ae0f80af0d73a5365c81f2e146709
author Jiri Slaby <jirislaby@gmail.com> Mon, 15 Oct 2007 15:44:58 +0200
committer Jiri Slaby <jirislaby@gmail.com> Mon, 15 Oct 2007 15:44:58 +0200

 drivers/char/rocket.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c
index 27bb0cd..a825316 100644
--- a/drivers/char/rocket.c
+++ b/drivers/char/rocket.c
@@ -548,8 +548,8 @@ static void rp_handle_port(struct r_port *info)
 static void rp_do_poll(unsigned long dummy)
 {
 	CONTROLLER_t *ctlp;
-	int ctrl, aiop, ch, line, i;
-	unsigned int xmitmask;
+	int ctrl, aiop, ch, line;
+	unsigned int xmitmask, i;
 	unsigned int CtlMask;
 	unsigned char AiopMask;
 	Word_t bit;

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

end of thread, other threads:[~2007-10-15 16:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-15 16:29 [PATCH 1/5] Char: rocket, fix dynamic_dev tty Jiri Slaby
2007-10-15 16:29 ` [PATCH 2/5] Char: rocket, don't re-set statics to 0 Jiri Slaby
2007-10-15 16:30 ` [PATCH 3/5] Char: rocket, remove pci_read_config_dword(CLASS_REVISION) Jiri Slaby
2007-10-15 16:31 ` [PATCH 4/5] Char: rocket, remove potential leak in module_init Jiri Slaby
2007-10-15 16:31 ` [PATCH 5/5] Char: rocket, fix signed/unsigned warning Jiri Slaby

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®