From: Jeff Garzik <jeff@garzik.org>
To: Andrew Morton <akpm@linux-foundation.org>, linux-scsi@vger.kernel.org
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 4/5] SCSI/initio PCI dev init factorization
Date: Sun, 27 May 2007 10:58:11 -0400 [thread overview]
Message-ID: <20070527145811.GD17085@havoc.gtf.org> (raw)
In-Reply-To: <20070527145200.GA17017@havoc.gtf.org>
Factor PCI device init into separate function. No code changes,
except for return value differences.
Signed-off-by: Jeff Garzik <jeff@garzik.org>
6714c073a9df8c923fbfc661a1f287dfd1a74852
diff --git a/drivers/scsi/initio.c b/drivers/scsi/initio.c
index 2bc2390..702dcf5 100644
--- a/drivers/scsi/initio.c
+++ b/drivers/scsi/initio.c
@@ -2742,38 +2742,53 @@ static irqreturn_t i91u_intr(int irqno, void *dev_id)
return IRQ_HANDLED;
}
+static int tul_pci_dev_init(struct pci_dev *pDev)
+{
+ long dRegValue;
+ WORD wBIOS;
+ int rc;
+
+ rc = pci_enable_device(pDev);
+ if (rc)
+ return rc;
+
+ pci_read_config_dword(pDev, 0x44, (u32 *) & dRegValue);
+ wBIOS = (UWORD) (dRegValue & 0xFF);
+ if (((dRegValue & 0xFF00) >> 8) == 0xFF)
+ dRegValue = 0;
+ wBIOS = (wBIOS << 8) + ((UWORD) ((dRegValue & 0xFF00) >> 8));
+
+ rc = pci_set_dma_mask(pDev, DMA_32BIT_MASK);
+ if (rc) {
+ printk(KERN_WARNING
+ "i91u: Could not set 32 bit DMA mask\n");
+ return rc;
+ }
+
+ rc = Addi91u_into_Adapter_table(wBIOS, pDev);
+ if (rc)
+ return -ENODEV;
+
+ return 0;
+}
+
static int tul_NewReturnNumberOfAdapters(void)
{
struct pci_dev *pDev = NULL; /* Start from none */
int iAdapters = 0;
- long dRegValue;
- WORD wBIOS;
- int i = 0;
+ int i;
init_i91uAdapter_table();
for (i = 0; i < ARRAY_SIZE(i91u_pci_devices); i++)
{
while ((pDev = pci_find_device(i91u_pci_devices[i].vendor, i91u_pci_devices[i].device, pDev)) != NULL) {
- if (pci_enable_device(pDev))
- continue;
- pci_read_config_dword(pDev, 0x44, (u32 *) & dRegValue);
- wBIOS = (UWORD) (dRegValue & 0xFF);
- if (((dRegValue & 0xFF00) >> 8) == 0xFF)
- dRegValue = 0;
- wBIOS = (wBIOS << 8) + ((UWORD) ((dRegValue & 0xFF00) >> 8));
- if (pci_set_dma_mask(pDev, DMA_32BIT_MASK)) {
- printk(KERN_WARNING
- "i91u: Could not set 32 bit DMA mask\n");
- continue;
- }
-
- if (Addi91u_into_Adapter_table(wBIOS, pDev) == 0)
+ if (tul_pci_dev_init(pDev) == 0)
iAdapters++;
}
}
- return (iAdapters);
+ return iAdapters;
}
static int i91u_detect(struct scsi_host_template * tpnt)
next prev parent reply other threads:[~2007-05-27 14:58 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-27 14:52 [PATCH 0/5] SCSI/initio fixes, cleanups, PCI API support Jeff Garzik
2007-05-27 14:53 ` [PATCH 1/5] SCSI/initio PCI DMA fix Jeff Garzik
2007-05-27 14:55 ` [PATCH 2/5] SCSI/initio pci_dev, pci_dev->irq simplifications Jeff Garzik
2007-05-27 14:57 ` [PATCH 3/5] SCSI/initio minor cleanups Jeff Garzik
2007-05-27 14:58 ` Jeff Garzik [this message]
2007-05-27 14:59 ` [PATCH 5/5] SCSI/initio conversion to PCI driver API Jeff Garzik
2007-05-27 15:03 ` Jeff Garzik
2007-05-27 15:12 ` James Bottomley
2007-05-27 15:45 ` Jeff Garzik
2007-05-27 15:48 ` Alan Cox
2007-05-27 15:47 ` [PATCH 0/5] SCSI/initio fixes, cleanups, PCI API support Alan Cox
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=20070527145811.GD17085@havoc.gtf.org \
--to=jeff@garzik.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®