lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sun, 27 May 2007 10:58:11 -0400
From:	Jeff Garzik <jeff@...zik.org>
To:	Andrew Morton <akpm@...ux-foundation.org>,
	linux-scsi@...r.kernel.org
Cc:	LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH 4/5] SCSI/initio PCI dev init factorization


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

Signed-off-by: Jeff Garzik <jeff@...zik.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)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ