]> err.no Git - linux-2.6/blobdiff - drivers/scsi/ips.c
drivers/scsi/: Spelling fixes
[linux-2.6] / drivers / scsi / ips.c
index 0da3dfa3150a2e5a29f74b8d3b4d7deb076113d6..bb152fb9fec7dc4b3260c2b4add978ba4af0e314 100644 (file)
@@ -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);
 
@@ -1313,7 +1309,7 @@ ips_intr_copperhead(ips_ha_t * ha)
                        cstatus.value = (*ha->func.statupd) (ha);
 
                if (cstatus.fields.command_id > (IPS_MAX_CMDS - 1)) {
-                       /* Spurious Interupt ? */
+                       /* Spurious Interrupt ? */
                        continue;
                }
 
@@ -2740,8 +2736,6 @@ ips_next(ips_ha_t * ha, int intr)
                SC->result = DID_OK;
                SC->host_scribble = NULL;
 
-               memset(SC->sense_buffer, 0, sizeof (SC->sense_buffer));
-
                scb->target_id = SC->device->id;
                scb->lun = SC->device->lun;
                scb->bus = SC->device->channel;
@@ -3439,13 +3433,11 @@ ips_map_status(ips_ha_t * ha, ips_scb_t * scb, ips_stat_t * sp)
                                            (IPS_DCDB_TABLE_TAPE *) & scb->dcdb;
                                        memcpy(scb->scsi_cmd->sense_buffer,
                                               tapeDCDB->sense_info,
-                                              sizeof (scb->scsi_cmd->
-                                                      sense_buffer));
+                                              SCSI_SENSE_BUFFERSIZE);
                                } else {
                                        memcpy(scb->scsi_cmd->sense_buffer,
                                               scb->dcdb.sense_info,
-                                              sizeof (scb->scsi_cmd->
-                                                      sense_buffer));
+                                              SCSI_SENSE_BUFFERSIZE);
                                }
                                device_error = 2;       /* check condition */
                        }
@@ -3825,7 +3817,6 @@ ips_send_cmd(ips_ha_t * ha, ips_scb_t * scb)
                        /* attempted, a Check Condition occurred, and Sense   */
                        /* Data indicating an Invalid CDB OpCode is returned. */
                        sp = (char *) scb->scsi_cmd->sense_buffer;
-                       memset(sp, 0, sizeof (scb->scsi_cmd->sense_buffer));
 
                        sp[0] = 0x70;   /* Error Code               */
                        sp[2] = ILLEGAL_REQUEST;        /* Sense Key 5 Illegal Req. */
@@ -4394,8 +4385,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;
 
        }
@@ -6843,13 +6832,10 @@ ips_register_scsi(int index)
        if (request_irq(ha->pcidev->irq, do_ipsintr, IRQF_SHARED, ips_name, ha)) {
                IPS_PRINTK(KERN_WARNING, ha->pcidev,
                           "Unable to install interrupt handler\n");
-               scsi_host_put(sh);
-               return -1;
+               goto err_out_sh;
        }
 
        kfree(oldha);
-       ips_sh[index] = sh;
-       ips_ha[index] = ha;
 
        /* Store away needed values for later use */
        sh->unique_id = (ha->io_addr) ? ha->io_addr : ha->mem_addr;
@@ -6865,10 +6851,21 @@ ips_register_scsi(int index)
        sh->max_channel = ha->nbus - 1;
        sh->can_queue = ha->max_cmds - 1;
 
-       scsi_add_host(sh, NULL);
+       if (scsi_add_host(sh, &ha->pcidev->dev))
+               goto err_out;
+
+       ips_sh[index] = sh;
+       ips_ha[index] = ha;
+
        scsi_scan_host(sh);
 
        return 0;
+
+err_out:
+       free_irq(ha->pcidev->irq, ha);
+err_out_sh:
+       scsi_host_put(sh);
+       return -1;
 }
 
 /*---------------------------------------------------------------------------*/
@@ -6880,20 +6877,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);
 }
 
 /****************************************************************************/
@@ -6947,12 +6938,17 @@ module_exit(ips_module_exit);
 static int __devinit
 ips_insert_device(struct pci_dev *pci_dev, const struct pci_device_id *ent)
 {
-       int uninitialized_var(index);
+       int index = -1;
        int rc;
 
        METHOD_TRACE("ips_insert_device", 1);
-       if (pci_enable_device(pci_dev))
-               return -1;
+       rc = pci_enable_device(pci_dev);
+       if (rc)
+               return rc;
+
+       rc = pci_request_regions(pci_dev, "ips");
+       if (rc)
+               goto err_out;
 
        rc = ips_init_phase1(pci_dev, &index);
        if (rc == SUCCESS)
@@ -6968,6 +6964,19 @@ ips_insert_device(struct pci_dev *pci_dev, const struct pci_device_id *ent)
                ips_num_controllers++;
 
        ips_next_controller = ips_num_controllers;
+
+       if (rc < 0) {
+               rc = -ENODEV;
+               goto err_out_regions;
+       }
+
+       pci_set_drvdata(pci_dev, ips_sh[index]);
+       return 0;
+
+err_out_regions:
+       pci_release_regions(pci_dev);
+err_out:
+       pci_disable_device(pci_dev);
        return rc;
 }
 
@@ -7000,7 +7009,7 @@ ips_init_phase1(struct pci_dev *pci_dev, int *indexPtr)
        METHOD_TRACE("ips_init_phase1", 1);
        index = IPS_MAX_ADAPTERS;
        for (j = 0; j < IPS_MAX_ADAPTERS; j++) {
-               if (ips_ha[j] == 0) {
+               if (ips_ha[j] == NULL) {
                        index = j;
                        break;
                }
@@ -7037,32 +7046,17 @@ ips_init_phase1(struct pci_dev *pci_dev, int *indexPtr)
                uint32_t base;
                uint32_t offs;
 
-               if (!request_mem_region(mem_addr, mem_len, "ips")) {
-                       IPS_PRINTK(KERN_WARNING, pci_dev,
-                                  "Couldn't allocate IO Memory space %x len %d.\n",
-                                  mem_addr, mem_len);
-                       return -1;
-               }
-
                base = mem_addr & PAGE_MASK;
                offs = mem_addr - base;
                ioremap_ptr = ioremap(base, PAGE_SIZE);
+               if (!ioremap_ptr)
+                       return -1;
                mem_ptr = ioremap_ptr + offs;
        } else {
                ioremap_ptr = NULL;
                mem_ptr = NULL;
        }
 
-       /* setup I/O mapped area (if applicable) */
-       if (io_addr) {
-               if (!request_region(io_addr, io_len, "ips")) {
-                       IPS_PRINTK(KERN_WARNING, pci_dev,
-                                  "Couldn't allocate IO space %x len %d.\n",
-                                  io_addr, io_len);
-                       return -1;
-               }
-       }
-
        /* found a controller */
        ha = kzalloc(sizeof (ips_ha_t), GFP_KERNEL);
        if (ha == NULL) {
@@ -7071,7 +7065,6 @@ ips_init_phase1(struct pci_dev *pci_dev, int *indexPtr)
                return -1;
        }
 
-
        ips_sh[index] = NULL;
        ips_ha[index] = ha;
        ha->active = 1;