public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Jamie Lenehan <lenehan@twibble.org>
To: linux-scsi@vger.kernel.org
Cc: dc395x@twibble.org
Subject: [PATCH] dc395x - 3/3 fix-failures
Date: Sun, 3 Aug 2003 18:29:29 +1000	[thread overview]
Message-ID: <20030803082929.GC4611@twibble.org> (raw)
In-Reply-To: <20030803082836.GB4611@twibble.org>

Handle the case where scsi_add_host fails and update the removal
function to correctly unregister everything.

diff -r -du a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c
--- a/drivers/scsi/dc395x.c	2003-08-03 18:09:08.178692696 +1000
+++ b/drivers/scsi/dc395x.c	2003-08-03 18:09:11.006262840 +1000
@@ -5807,6 +5807,7 @@
 	u8 irq;
 	struct Scsi_Host *scsi_host;
 	static int banner_done = 0;
+	int error = 0;
 
 	dprintkdbg(DBG_0, "Init one instance of the dc395x\n");
 	if (!banner_done)
@@ -5832,20 +5833,21 @@
 		dprintkdbg(DBG_0, "host_init failed\n");
 		return -ENOMEM;
 	}
-
-	pci_set_master(dev);
-
-	/* store pci devices in out host data object. */
 	((struct AdapterCtlBlk *)(scsi_host->hostdata))->dev = dev;
-
-	/* store ptr to scsi host in the PCI device structure */
+	pci_set_master(dev);
 	pci_set_drvdata(dev, scsi_host);
 
 	/* get the scsi mid level to scan for new devices on the bus */
-	scsi_add_host(scsi_host, &dev->dev);	/* XXX handle failure */
-	scsi_scan_host(scsi_host);
-
-	return 0;
+	error = scsi_add_host(scsi_host, &dev->dev);
+	if (error) {
+		dprintkl(KERN_ERR, "scsi_add_host failed\n");
+                error = -ENODEV;
+                host_release(scsi_host);
+                scsi_host_put(scsi_host);
+	} else
+        	scsi_scan_host(scsi_host);
+        	
+	return error;
 }
 
 
@@ -5858,9 +5860,18 @@
 static void __devexit dc395x_remove_one(struct pci_dev *dev)
 {
 	struct Scsi_Host *host = pci_get_drvdata(dev);
+
 	dprintkdbg(DBG_0, "Removing instance\n");
-	scsi_remove_host(host);
+	if (!host) {
+		dprintkl(KERN_ERR, "no host allocated\n");
+		return;
+	}
+	if (scsi_remove_host(host)) {
+		dprintkl(KERN_ERR, "scsi_remove_host failed\n");
+		return;
+	}
 	host_release(host);
+	scsi_host_put(host);
 	pci_set_drvdata(dev, NULL);
 }
 

-- 
 Jamie Lenehan              Work Phone: +61 3 9843 8817
 lenehan@twibble.org        Work Email: jamie.lenehan@activcard.com.au

  reply	other threads:[~2003-08-03  8:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-03  8:27 [PATCH] dc395x - description Jamie Lenehan
2003-08-03  8:27 ` [PATCH] dc395x - 1/3 remove-static-eeprom-struct Jamie Lenehan
2003-08-03  8:28   ` [PATCH] dc395x - 2/3 remove-static-adapter-list Jamie Lenehan
2003-08-03  8:29     ` Jamie Lenehan [this message]
2003-08-03 15:01   ` [PATCH] dc395x - 1/3 remove-static-eeprom-struct James Bottomley
2003-08-03 15:04     ` [Dc395x] " Ali Akcaagac
2003-08-03 15:13       ` James Bottomley
2003-08-03 15:36         ` Ali Akcaagac
2003-08-03 17:31           ` James Bottomley
2003-08-12  4:12             ` Ali Akcaagac
2003-08-12 10:29               ` Jamie Lenehan

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=20030803082929.GC4611@twibble.org \
    --to=lenehan@twibble.org \
    --cc=dc395x@twibble.org \
    --cc=linux-scsi@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox