Factor PCI device init into separate function.  No code changes,
except for return value differences.

Signed-off-by: Jeff Garzik <[EMAIL PROTECTED]>

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)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to