RE: [PATCH 3/4] [SCSI] ips: PCI API cleanups

Previous thread: [PATCH 2/4] [SCSI] ips: trim trailing whitespace by Jeff Garzik on Wednesday, October 24, 2007 - 4:48 pm. (2 messages)

Next thread: [PATCH 4/4] [SCSI] ips: handle scsi_add_host() failure, and other err cleanups by Jeff Garzik on Wednesday, October 24, 2007 - 4:48 pm. (2 messages)
From: Jeff Garzik
Date: Wednesday, October 24, 2007 - 4:48 pm

* pass Scsi_Host to ips_remove_device() via pci_set_drvdata(),
  allowing us to eliminate the ips_ha[] search loop and call
  ips_release() directly.

* call pci_{request,release}_regions() and eliminate individual
  request/release_[mem_]region() calls

* call pci_disable_device(), paired with pci_enable_device()

* s/0/NULL/ in a few places

* check ioremap() return value

Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
---
 drivers/scsi/ips.c |   72 ++++++++++++++++++++++-----------------------------
 1 files changed, 31 insertions(+), 41 deletions(-)

diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c
index c9f3e1f..fb90b6c 100644
--- a/drivers/scsi/ips.c
+++ b/drivers/scsi/ips.c
@@ -702,10 +702,6 @@ ips_release(struct Scsi_Host *sh)
 	/* free extra memory */
 	ips_free(ha);
 
-	/* Free I/O Region */
-	if (ha->io_addr)
-		release_region(ha->io_addr, ha->io_len);
-
 	/* free IRQ */
 	free_irq(ha->pcidev->irq, ha);
 
@@ -4393,8 +4389,6 @@ ips_free(ips_ha_t * ha)
 			ha->mem_ptr = NULL;
 		}
 
-		if (ha->mem_addr)
-			release_mem_region(ha->mem_addr, ha->mem_len);
 		ha->mem_addr = 0;
 
 	}
@@ -6879,20 +6873,14 @@ ips_register_scsi(int index)
 static void __devexit
 ips_remove_device(struct pci_dev *pci_dev)
 {
-	int i;
-	struct Scsi_Host *sh;
-	ips_ha_t *ha;
+	struct Scsi_Host *sh = pci_get_drvdata(pci_dev);
 
-	for (i = 0; i < IPS_MAX_ADAPTERS; i++) {
-		ha = ips_ha[i];
-		if (ha) {
-			if ((pci_dev->bus->number == ha->pcidev->bus->number) &&
-			    (pci_dev->devfn == ha->pcidev->devfn)) {
-				sh = ips_sh[i];
-				ips_release(sh);
-			}
-		}
-	}
+	pci_set_drvdata(pci_dev, NULL);
+
+	ips_release(sh);
+
+	pci_release_regions(pci_dev);
+	pci_disable_device(pci_dev);
 }
 
 /****************************************************************************/
@@ -6946,12 +6934,17 @@ module_exit(ips_module_exit);
 static int __devinit
 ips_insert_device(struct pci_dev *pci_dev, const struct pci_device_id *ent)
 {
-	int ...
From: Rolf Eike Beer
Date: Wednesday, October 24, 2007 - 11:54 pm

This looks odd. What are we actually doing here?

It seems that we want to map that PCI BAR. Since we're playing with PAGE_MA=
SK=20
I assume the BAR always has a length <PAGE_SIZE, else we would get page=20
aligned memory anyway. If that's true something like

mem_ptr =3D pci_iomap(pci_dev, bar, 0)

should do the trick. Later we would do

pci_iounmap(pci_dev, mem_ptr)

This whole ioremap_ptr stuff can go away at all. Am I right? Then I'll cook=
 up=20
a patch soon.

Eike
From: Salyzyn, Mark
Date: Thursday, October 25, 2007 - 7:37 am

ACK. Inspected only. Looks ok.

-

Previous thread: [PATCH 2/4] [SCSI] ips: trim trailing whitespace by Jeff Garzik on Wednesday, October 24, 2007 - 4:48 pm. (2 messages)

Next thread: [PATCH 4/4] [SCSI] ips: handle scsi_add_host() failure, and other err cleanups by Jeff Garzik on Wednesday, October 24, 2007 - 4:48 pm. (2 messages)