aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/ips.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/ips.c')
-rw-r--r--drivers/scsi/ips.c72
1 files changed, 31 insertions, 41 deletions
diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c
index 0da3dfa3150a..5f194a807f94 100644
--- a/drivers/scsi/ips.c
+++ b/drivers/scsi/ips.c
@@ -702,10 +702,6 @@ ips_release(struct Scsi_Host *sh)
702 /* free extra memory */ 702 /* free extra memory */
703 ips_free(ha); 703 ips_free(ha);
704 704
705 /* Free I/O Region */
706 if (ha->io_addr)
707 release_region(ha->io_addr, ha->io_len);
708
709 /* free IRQ */ 705 /* free IRQ */
710 free_irq(ha->pcidev->irq, ha); 706 free_irq(ha->pcidev->irq, ha);
711 707
@@ -4394,8 +4390,6 @@ ips_free(ips_ha_t * ha)
4394 ha->mem_ptr = NULL; 4390 ha->mem_ptr = NULL;
4395 } 4391 }
4396 4392
4397 if (ha->mem_addr)
4398 release_mem_region(ha->mem_addr, ha->mem_len);
4399 ha->mem_addr = 0; 4393 ha->mem_addr = 0;
4400 4394
4401 } 4395 }
@@ -6880,20 +6874,14 @@ ips_register_scsi(int index)
6880static void __devexit 6874static void __devexit
6881ips_remove_device(struct pci_dev *pci_dev) 6875ips_remove_device(struct pci_dev *pci_dev)
6882{ 6876{
6883 int i; 6877 struct Scsi_Host *sh = pci_get_drvdata(pci_dev);
6884 struct Scsi_Host *sh;
6885 ips_ha_t *ha;
6886 6878
6887 for (i = 0; i < IPS_MAX_ADAPTERS; i++) { 6879 pci_set_drvdata(pci_dev, NULL);
6888 ha = ips_ha[i]; 6880
6889 if (ha) { 6881 ips_release(sh);
6890 if ((pci_dev->bus->number == ha->pcidev->bus->number) && 6882
6891 (pci_dev->devfn == ha->pcidev->devfn)) { 6883 pci_release_regions(pci_dev);
6892 sh = ips_sh[i]; 6884 pci_disable_device(pci_dev);
6893 ips_release(sh);
6894 }
6895 }
6896 }
6897} 6885}
6898 6886
6899/****************************************************************************/ 6887/****************************************************************************/
@@ -6947,12 +6935,17 @@ module_exit(ips_module_exit);
6947static int __devinit 6935static int __devinit
6948ips_insert_device(struct pci_dev *pci_dev, const struct pci_device_id *ent) 6936ips_insert_device(struct pci_dev *pci_dev, const struct pci_device_id *ent)
6949{ 6937{
6950 int uninitialized_var(index); 6938 int index = -1;
6951 int rc; 6939 int rc;
6952 6940
6953 METHOD_TRACE("ips_insert_device", 1); 6941 METHOD_TRACE("ips_insert_device", 1);
6954 if (pci_enable_device(pci_dev)) 6942 rc = pci_enable_device(pci_dev);
6955 return -1; 6943 if (rc)
6944 return rc;
6945
6946 rc = pci_request_regions(pci_dev, "ips");
6947 if (rc)
6948 goto err_out;
6956 6949
6957 rc = ips_init_phase1(pci_dev, &index); 6950 rc = ips_init_phase1(pci_dev, &index);
6958 if (rc == SUCCESS) 6951 if (rc == SUCCESS)
@@ -6968,6 +6961,19 @@ ips_insert_device(struct pci_dev *pci_dev, const struct pci_device_id *ent)
6968 ips_num_controllers++; 6961 ips_num_controllers++;
6969 6962
6970 ips_next_controller = ips_num_controllers; 6963 ips_next_controller = ips_num_controllers;
6964
6965 if (rc < 0) {
6966 rc = -ENODEV;
6967 goto err_out_regions;
6968 }
6969
6970 pci_set_drvdata(pci_dev, ips_sh[index]);
6971 return 0;
6972
6973err_out_regions:
6974 pci_release_regions(pci_dev);
6975err_out:
6976 pci_disable_device(pci_dev);
6971 return rc; 6977 return rc;
6972} 6978}
6973 6979
@@ -7000,7 +7006,7 @@ ips_init_phase1(struct pci_dev *pci_dev, int *indexPtr)
7000 METHOD_TRACE("ips_init_phase1", 1); 7006 METHOD_TRACE("ips_init_phase1", 1);
7001 index = IPS_MAX_ADAPTERS; 7007 index = IPS_MAX_ADAPTERS;
7002 for (j = 0; j < IPS_MAX_ADAPTERS; j++) { 7008 for (j = 0; j < IPS_MAX_ADAPTERS; j++) {
7003 if (ips_ha[j] == 0) { 7009 if (ips_ha[j] == NULL) {
7004 index = j; 7010 index = j;
7005 break; 7011 break;
7006 } 7012 }
@@ -7037,32 +7043,17 @@ ips_init_phase1(struct pci_dev *pci_dev, int *indexPtr)
7037 uint32_t base; 7043 uint32_t base;
7038 uint32_t offs; 7044 uint32_t offs;
7039 7045
7040 if (!request_mem_region(mem_addr, mem_len, "ips")) {
7041 IPS_PRINTK(KERN_WARNING, pci_dev,
7042 "Couldn't allocate IO Memory space %x len %d.\n",
7043 mem_addr, mem_len);
7044 return -1;
7045 }
7046
7047 base = mem_addr & PAGE_MASK; 7046 base = mem_addr & PAGE_MASK;
7048 offs = mem_addr - base; 7047 offs = mem_addr - base;
7049 ioremap_ptr = ioremap(base, PAGE_SIZE); 7048 ioremap_ptr = ioremap(base, PAGE_SIZE);
7049 if (!ioremap_ptr)
7050 return -1;
7050 mem_ptr = ioremap_ptr + offs; 7051 mem_ptr = ioremap_ptr + offs;
7051 } else { 7052 } else {
7052 ioremap_ptr = NULL; 7053 ioremap_ptr = NULL;
7053 mem_ptr = NULL; 7054 mem_ptr = NULL;
7054 } 7055 }
7055 7056
7056 /* setup I/O mapped area (if applicable) */
7057 if (io_addr) {
7058 if (!request_region(io_addr, io_len, "ips")) {
7059 IPS_PRINTK(KERN_WARNING, pci_dev,
7060 "Couldn't allocate IO space %x len %d.\n",
7061 io_addr, io_len);
7062 return -1;
7063 }
7064 }
7065
7066 /* found a controller */ 7057 /* found a controller */
7067 ha = kzalloc(sizeof (ips_ha_t), GFP_KERNEL); 7058 ha = kzalloc(sizeof (ips_ha_t), GFP_KERNEL);
7068 if (ha == NULL) { 7059 if (ha == NULL) {
@@ -7071,7 +7062,6 @@ ips_init_phase1(struct pci_dev *pci_dev, int *indexPtr)
7071 return -1; 7062 return -1;
7072 } 7063 }
7073 7064
7074
7075 ips_sh[index] = NULL; 7065 ips_sh[index] = NULL;
7076 ips_ha[index] = ha; 7066 ips_ha[index] = ha;
7077 ha->active = 1; 7067 ha->active = 1;