public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Stephen M. Cameron" <scameron@beardog.cce.hp.com>
To: James.Bottomley@HansenPartnership.com, akpm@linux-foundation.org
Cc: mikem@beardog.cce.hp.com, brace@beardog.cce.hp.com,
	matthew.gates@hp.com, linux-scsi@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 07/30] hpsa: return proper error codes not minus one.
Date: Thu, 04 Feb 2010 08:41:59 -0600	[thread overview]
Message-ID: <20100204144159.10406.19763.stgit@beardog.cce.hp.com> (raw)
In-Reply-To: <20100204144012.10406.14868.stgit@beardog.cce.hp.com>

From: Stephen M. Cameron <scameron@beardog.cce.hp.com>

hpsa: return proper error codes not minus one.

Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
---
 drivers/scsi/hpsa.c |   37 ++++++++++++++++++++++---------------
 1 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 9017e64..8389cce 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -1130,11 +1130,11 @@ static int hpsa_scsi_detect(struct ctlr_info *h)
 	dev_err(&h->pdev->dev, "hpsa_scsi_detect: scsi_add_host"
 		" failed for controller %d\n", h->ctlr);
 	scsi_host_put(sh);
-	return -1;
+	return error;
  fail:
 	dev_err(&h->pdev->dev, "hpsa_scsi_detect: scsi_host_alloc"
 		" failed for controller %d\n", h->ctlr);
-	return -1;
+	return -ENOMEM;
 }
 
 static void hpsa_pci_unmap(struct pci_dev *pdev,
@@ -1271,7 +1271,7 @@ static int hpsa_scsi_do_inquiry(struct ctlr_info *h, unsigned char *scsi3addr,
 
 	if (c == NULL) {			/* trouble... */
 		dev_warn(&h->pdev->dev, "cmd_special_alloc returned NULL!\n");
-		return -1;
+		return -ENOMEM;
 	}
 
 	fill_cmd(c, HPSA_INQUIRY, h, buf, bufsize, page, scsi3addr, TYPE_CMD);
@@ -3284,7 +3284,7 @@ err_out_free_res:
 static int __devinit hpsa_init_one(struct pci_dev *pdev,
 				    const struct pci_device_id *ent)
 {
-	int i;
+	int i, rc;
 	int dac;
 	struct ctlr_info *h;
 
@@ -3312,14 +3312,15 @@ static int __devinit hpsa_init_one(struct pci_dev *pdev,
 	BUILD_BUG_ON(sizeof(struct CommandList) % 8);
 	h = kzalloc(sizeof(*h), GFP_KERNEL);
 	if (!h)
-		return -1;
+		return -ENOMEM;
 
 	h->busy_initializing = 1;
 	INIT_HLIST_HEAD(&h->cmpQ);
 	INIT_HLIST_HEAD(&h->reqQ);
 	mutex_init(&h->busy_shutting_down);
 	init_completion(&h->scan_wait);
-	if (hpsa_pci_init(h, pdev) != 0)
+	rc = hpsa_pci_init(h, pdev);
+	if (rc != 0)
 		goto clean1;
 
 	sprintf(h->devname, "hpsa%d", number_of_controllers);
@@ -3328,19 +3329,24 @@ static int __devinit hpsa_init_one(struct pci_dev *pdev,
 	h->pdev = pdev;
 
 	/* configure PCI DMA stuff */
-	if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64)))
+	rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
+	if (rc == 0) {
 		dac = 1;
-	else if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32)))
-		dac = 0;
-	else {
-		dev_err(&pdev->dev, "no suitable DMA available\n");
-		goto clean1;
+	} else {
+		rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
+		if (rc == 0) {
+			dac = 0;
+		} else {
+			dev_err(&pdev->dev, "no suitable DMA available\n");
+			goto clean1;
+		}
 	}
 
 	/* make sure the board interrupts are off */
 	h->access.set_intr_mask(h, HPSA_INTR_OFF);
-	if (request_irq(h->intr[SIMPLE_MODE_INT], do_hpsa_intr,
-			IRQF_DISABLED | IRQF_SHARED, h->devname, h)) {
+	rc = request_irq(h->intr[SIMPLE_MODE_INT], do_hpsa_intr,
+			IRQF_DISABLED | IRQF_SHARED, h->devname, h);
+	if (rc) {
 		dev_err(&pdev->dev, "unable to get irq %d for %s\n",
 		       h->intr[SIMPLE_MODE_INT], h->devname);
 		goto clean2;
@@ -3363,6 +3369,7 @@ static int __devinit hpsa_init_one(struct pci_dev *pdev,
 	    || (h->cmd_pool == NULL)
 	    || (h->errinfo_pool == NULL)) {
 		dev_err(&pdev->dev, "out of memory");
+		rc = -ENOMEM;
 		goto clean4;
 	}
 	spin_lock_init(&h->lock);
@@ -3397,7 +3404,7 @@ clean2:
 clean1:
 	h->busy_initializing = 0;
 	kfree(h);
-	return -1;
+	return rc;
 }
 
 static void hpsa_flush_cache(struct ctlr_info *h)


  parent reply	other threads:[~2010-02-04 14:39 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-04 14:41 [PATCH 00/30] hpsa: Feb 2010 driver updates Stephen M. Cameron
2010-02-04 14:41 ` [PATCH 01/30] hpsa: fix typo in comments Stephen M. Cameron
2010-02-04 14:41 ` [PATCH 02/30] hpsa: Use kernel integer types, not userland ones Stephen M. Cameron
2010-02-04 14:41 ` [PATCH 03/30] hpsa: avoid unwanted promotion from unsigned to signed for raid level index Stephen M. Cameron
2010-02-04 14:41 ` [PATCH 04/30] hpsa: Use BUG_ON instead of an if statement Stephen M. Cameron
2010-02-04 14:41 ` [PATCH 05/30] hpsa: make adjust_hpsa_scsi_table return void Stephen M. Cameron
2010-02-04 14:41 ` [PATCH 06/30] hpsa: remove superfluous returns from void functions Stephen M. Cameron
2010-02-04 14:41 ` Stephen M. Cameron [this message]
2010-02-04 14:42 ` [PATCH 08/30] hpsa: use sizeof() not an inline constant in memset Stephen M. Cameron
2010-02-04 14:42 ` [PATCH 09/30] hpsa: use kzalloc not kmalloc plus memset Stephen M. Cameron
2010-02-04 14:42 ` [PATCH 10/30] hpsa: remove unwanted debug code Stephen M. Cameron
2010-02-04 14:42 ` [PATCH 11/30] hpsa: eliminate unnecessary memcpys Stephen M. Cameron
2010-02-04 14:42 ` [PATCH 12/30] hpsa: make tag macros into functions Stephen M. Cameron
2010-02-04 14:42 ` [PATCH 13/30] hpsa: fix some debug printks to use dev_dbg instead Stephen M. Cameron
2010-02-04 14:42 ` [PATCH 14/30] hpsa: interrupt pending function should return bool not unsigned long Stephen M. Cameron
2010-02-04 14:42 ` [PATCH 15/30] hpsa: Allow multiple command completions per interrupt Stephen M. Cameron
2010-02-04 14:42 ` [PATCH 16/30] hpsa: add pci ids for storageworks 1210m, remove p400, p800, p700m Stephen M. Cameron
2010-02-04 14:42 ` [PATCH 17/30] hpsa: Fix p1210m LUN assignment Stephen M. Cameron
2010-02-04 14:42 ` [PATCH 18/30] hpsa: Return DID_RESET for commands which complete with status of UNSOLICITED ABORT Stephen M. Cameron
2010-02-04 14:43 ` [PATCH 19/30] hpsa: Retry commands completing with a sense key of ABORTED_COMMAND Stephen M. Cameron
2010-02-04 14:43 ` [PATCH 20/30] hpsa: Don't return DID_NO_CONNECT when a device is merely not ready Stephen M. Cameron
2010-02-04 14:43 ` [PATCH 21/30] hpsa: Add an shost_to_hba helper function Stephen M. Cameron
2010-02-04 14:43 ` [PATCH 22/30] hpsa: use scan_start and scan_finished entry points for scanning Stephen M. Cameron
2010-02-04 14:43 ` [PATCH 23/30] hpsa: when resetting devices, print out which device Stephen M. Cameron
2010-02-04 14:43 ` [PATCH 24/30] hpsa: print all the bytes of the CDB, not just the first one Stephen M. Cameron
2010-02-04 14:43 ` [PATCH 25/30] hpsa: clarify obscure comment in adjust_hpsa_scsi_table Stephen M. Cameron
2010-02-04 14:43 ` [PATCH 26/30] hpsa: Fix hpsa_find_scsi_entry so that it doesn't try to dereference NULL pointers Stephen M. Cameron
2010-02-04 14:43 ` [PATCH 27/30] hpsa: fix bug in adjust_hpsa_scsi_table Stephen M. Cameron
2010-02-04 14:43 ` [PATCH 28/30] hpsa: eliminate lock_kernel in compat_ioctl Stephen M. Cameron
2010-02-04 14:43 ` [PATCH 29/30] hpsa: Reorder compat ioctl functions to eliminate some forward declarations Stephen M. Cameron
2010-02-04 14:43 ` [PATCH 30/30] hpsa: `update driver version to 2.0.1-3 Stephen M. Cameron

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=20100204144159.10406.19763.stgit@beardog.cce.hp.com \
    --to=scameron@beardog.cce.hp.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=akpm@linux-foundation.org \
    --cc=brace@beardog.cce.hp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=matthew.gates@hp.com \
    --cc=mikem@beardog.cce.hp.com \
    /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