All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Slaby <jirislaby@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: <linux-kernel@vger.kernel.org>
Subject: [PATCH 8/11] Char: cyclades, cy_init error handling
Date: Wed, 18 Apr 2007 12:06:53 +0200 (CEST)	[thread overview]
Message-ID: <3022717953242262423@karneval.cz> (raw)
In-Reply-To: <2428225437641930190@karneval.cz>

cyclades, cy_init error handling

- do not panic if tty_register_driver fails
- handle fail paths properly

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

---
commit 8c76c370ee1c1efa31f64807162c15922fae1e3a
tree 19fe12eba568aece1d0b406a4d735f393f2cd3dd
parent b1b13ea51dcaef72c5298a04d233b92206adf978
author Jiri Slaby <jirislaby@gmail.com> Mon, 02 Apr 2007 15:47:49 +0200
committer Jiri Slaby <jirislaby@gmail.com> Tue, 10 Apr 2007 10:48:06 +0200

 drivers/char/cyclades.c |   23 +++++++++++++++++++----
 1 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index 1baf7d7..22f8ec4 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -5460,10 +5460,11 @@ static const struct tty_operations cy_ops = {
 static int __init cy_init(void)
 {
 	unsigned int i, nboards;
+	int retval = -ENOMEM;
 
 	cy_serial_driver = alloc_tty_driver(NR_PORTS);
 	if (!cy_serial_driver)
-		return -ENOMEM;
+		goto err;
 	show_version();
 
 	/* Initialize the tty_driver structure */
@@ -5481,8 +5482,11 @@ static int __init cy_init(void)
 	cy_serial_driver->flags = TTY_DRIVER_REAL_RAW;
 	tty_set_operations(cy_serial_driver, &cy_ops);
 
-	if (tty_register_driver(cy_serial_driver))
-		panic("Couldn't register Cyclades serial driver\n");
+	retval = tty_register_driver(cy_serial_driver);
+	if (retval) {
+		printk(KERN_ERR "Couldn't register Cyclades serial driver\n");
+		goto err_frtty;
+	}
 
 	for (i = 0; i < NR_CARDS; i++) {
 		/* base_addr=0 indicates board not found */
@@ -5508,7 +5512,18 @@ static int __init cy_init(void)
 	/* look for pci boards */
 	nboards += cy_detect_pci();
 
-	return nboards ? 0 : -ENODEV;
+	if (nboards == 0) {
+		retval = -ENODEV;
+		goto err_unr;
+	}
+
+	return 0;
+err_unr:
+	tty_unregister_driver(cy_serial_driver);
+err_frtty:
+	put_tty_driver(cy_serial_driver);
+err:
+	return retval;
 }				/* cy_init */
 
 static void __exit cy_cleanup_module(void)

  parent reply	other threads:[~2007-04-18 10:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-18 10:03 [PATCH 1/11] Char: cyclades, create cy_init_Ze Jiri Slaby
2007-04-18 10:03 ` [PATCH 2/11] Char: cyclades, use pci_iomap/unmap Jiri Slaby
2007-04-18 10:04 ` [PATCH 3/11] Char: cyclades, init Ze immediately Jiri Slaby
2007-04-18 10:04 ` [PATCH 4/11] Char: cyclades, create cy_pci_probe Jiri Slaby
2007-04-18 10:05 ` [PATCH 5/11] Char: cyclades, move card entries init into function Jiri Slaby
2007-04-18 10:05 ` [PATCH 6/11] Char: cyclades, init card struct immediately Jiri Slaby
2007-04-18 10:06 ` [PATCH 7/11] Char: cyclades, remove some global vars Jiri Slaby
2007-04-18 10:06 ` Jiri Slaby [this message]
2007-04-18 10:07 ` [PATCH 9/11] Char: cyclades, tty_register_device separately for each device Jiri Slaby
2007-04-18 10:07 ` [PATCH 10/11] Char: cyclades, clear interrupts before releasing Jiri Slaby
2007-04-20  4:51   ` Andrew Morton
2007-04-18 10:08 ` [PATCH 11/11] Char: cyclades, allow DEBUG_SHIRQ Jiri Slaby

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3022717953242262423@karneval.cz \
    --to=jirislaby@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.