fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / scsi / ips.c
index 86c5461..8b704f7 100644 (file)
 
 #include <linux/blkdev.h>
 #include <linux/types.h>
+#include <linux/dma-mapping.h>
 
 #include <scsi/sg.h>
-
 #include "scsi.h"
-
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,0)
-#include "hosts.h"
-#else
 #include <scsi/scsi_host.h>
-#endif
 
 #include "ips.h"
 
 #include <linux/module.h>
 
 #include <linux/stat.h>
-#include <linux/config.h>
 
 #include <linux/spinlock.h>
 #include <linux/init.h>
@@ -250,11 +244,11 @@ module_param(ips, charp, 0);
  */
 static int ips_detect(struct scsi_host_template *);
 static int ips_release(struct Scsi_Host *);
-static int ips_eh_abort(Scsi_Cmnd *);
-static int ips_eh_reset(Scsi_Cmnd *);
-static int ips_queue(Scsi_Cmnd *, void (*)(Scsi_Cmnd *));
+static int ips_eh_abort(struct scsi_cmnd *);
+static int ips_eh_reset(struct scsi_cmnd *);
+static int ips_queue(struct scsi_cmnd *, void (*)(struct scsi_cmnd *));
 static const char *ips_info(struct Scsi_Host *);
-static irqreturn_t do_ipsintr(int, void *, struct pt_regs *);
+static irqreturn_t do_ipsintr(int, void *);
 static int ips_hainit(ips_ha_t *);
 static int ips_map_status(ips_ha_t *, ips_scb_t *, ips_stat_t *);
 static int ips_send_wait(ips_ha_t *, ips_scb_t *, int, int);
@@ -325,24 +319,26 @@ static uint32_t ips_statupd_copperhead_memio(ips_ha_t *);
 static uint32_t ips_statupd_morpheus(ips_ha_t *);
 static ips_scb_t *ips_getscb(ips_ha_t *);
 static void ips_putq_scb_head(ips_scb_queue_t *, ips_scb_t *);
-static void ips_putq_wait_tail(ips_wait_queue_t *, Scsi_Cmnd *);
+static void ips_putq_wait_tail(ips_wait_queue_t *, struct scsi_cmnd *);
 static void ips_putq_copp_tail(ips_copp_queue_t *,
                                      ips_copp_wait_item_t *);
 static ips_scb_t *ips_removeq_scb_head(ips_scb_queue_t *);
 static ips_scb_t *ips_removeq_scb(ips_scb_queue_t *, ips_scb_t *);
-static Scsi_Cmnd *ips_removeq_wait_head(ips_wait_queue_t *);
-static Scsi_Cmnd *ips_removeq_wait(ips_wait_queue_t *, Scsi_Cmnd *);
+static struct scsi_cmnd *ips_removeq_wait_head(ips_wait_queue_t *);
+static struct scsi_cmnd *ips_removeq_wait(ips_wait_queue_t *,
+                                         struct scsi_cmnd *);
 static ips_copp_wait_item_t *ips_removeq_copp(ips_copp_queue_t *,
                                                     ips_copp_wait_item_t *);
 static ips_copp_wait_item_t *ips_removeq_copp_head(ips_copp_queue_t *);
 
-static int ips_is_passthru(Scsi_Cmnd *);
-static int ips_make_passthru(ips_ha_t *, Scsi_Cmnd *, ips_scb_t *, int);
+static int ips_is_passthru(struct scsi_cmnd *);
+static int ips_make_passthru(ips_ha_t *, struct scsi_cmnd *, ips_scb_t *, int);
 static int ips_usrcmd(ips_ha_t *, ips_passthru_t *, ips_scb_t *);
 static void ips_cleanup_passthru(ips_ha_t *, ips_scb_t *);
-static void ips_scmd_buf_write(Scsi_Cmnd * scmd, void *data,
+static void ips_scmd_buf_write(struct scsi_cmnd * scmd, void *data,
                               unsigned int count);
-static void ips_scmd_buf_read(Scsi_Cmnd * scmd, void *data, unsigned int count);
+static void ips_scmd_buf_read(struct scsi_cmnd * scmd, void *data,
+                             unsigned int count);
 
 static int ips_proc_info(struct Scsi_Host *, char *, char **, off_t, int, int);
 static int ips_host_info(ips_ha_t *, char *, off_t, int);
@@ -555,7 +551,7 @@ ips_setup(char *ips_str)
                 * We now have key/value pairs.
                 * Update the variables
                 */
-               for (i = 0; i < (sizeof (options) / sizeof (options[0])); i++) {
+               for (i = 0; i < ARRAY_SIZE(options); i++) {
                        if (strnicmp
                            (key, options[i].option_name,
                             strlen(options[i].option_name)) == 0) {
@@ -812,8 +808,7 @@ ips_halt(struct notifier_block *nb, ulong event, void *buf)
 /*   Abort a command (using the new error code stuff)                       */
 /* Note: this routine is called under the io_request_lock                   */
 /****************************************************************************/
-int
-ips_eh_abort(Scsi_Cmnd * SC)
+int ips_eh_abort(struct scsi_cmnd *SC)
 {
        ips_ha_t *ha;
        ips_copp_wait_item_t *item;
@@ -871,8 +866,7 @@ ips_eh_abort(Scsi_Cmnd * SC)
 /* NOTE: this routine is called under the io_request_lock spinlock          */
 /*                                                                          */
 /****************************************************************************/
-static int
-__ips_eh_reset(Scsi_Cmnd * SC)
+static int __ips_eh_reset(struct scsi_cmnd *SC)
 {
        int ret;
        int i;
@@ -968,7 +962,7 @@ __ips_eh_reset(Scsi_Cmnd * SC)
        ret = (*ha->func.reset) (ha);
 
        if (!ret) {
-               Scsi_Cmnd *scsi_cmd;
+               struct scsi_cmnd *scsi_cmd;
 
                IPS_PRINTK(KERN_NOTICE, ha->pcidev,
                           "Controller reset failed - controller now offline.\n");
@@ -997,7 +991,7 @@ __ips_eh_reset(Scsi_Cmnd * SC)
        }
 
        if (!ips_clear_adapter(ha, IPS_INTR_IORL)) {
-               Scsi_Cmnd *scsi_cmd;
+               struct scsi_cmnd *scsi_cmd;
 
                IPS_PRINTK(KERN_NOTICE, ha->pcidev,
                           "Controller reset failed - controller now offline.\n");
@@ -1059,8 +1053,7 @@ __ips_eh_reset(Scsi_Cmnd * SC)
 
 }
 
-static int
-ips_eh_reset(Scsi_Cmnd * SC)
+static int ips_eh_reset(struct scsi_cmnd *SC)
 {
        int rc;
 
@@ -1083,8 +1076,7 @@ ips_eh_reset(Scsi_Cmnd * SC)
 /*    Linux obtains io_request_lock before calling this function            */
 /*                                                                          */
 /****************************************************************************/
-static int
-ips_queue(Scsi_Cmnd * SC, void (*done) (Scsi_Cmnd *))
+static int ips_queue(struct scsi_cmnd *SC, void (*done) (struct scsi_cmnd *))
 {
        ips_ha_t *ha;
        ips_passthru_t *pt;
@@ -1146,7 +1138,7 @@ ips_queue(Scsi_Cmnd * SC, void (*done) (Scsi_Cmnd *))
                                return (0);
                        }
                        ha->ioctl_reset = 1;    /* This reset request is from an IOCTL */
-                       ips_eh_reset(SC);
+                       __ips_eh_reset(SC);
                        SC->result = DID_OK << 16;
                        SC->scsi_done(SC);
                        return (0);
@@ -1336,7 +1328,7 @@ ips_slave_configure(struct scsi_device * SDptr)
 /*                                                                          */
 /****************************************************************************/
 static irqreturn_t
-do_ipsintr(int irq, void *dev_id, struct pt_regs * regs)
+do_ipsintr(int irq, void *dev_id)
 {
        ips_ha_t *ha;
        unsigned long cpu_flags;
@@ -1602,8 +1594,7 @@ ips_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset,
 /*   Determine if the specified SCSI command is really a passthru command   */
 /*                                                                          */
 /****************************************************************************/
-static int
-ips_is_passthru(Scsi_Cmnd * SC)
+static int ips_is_passthru(struct scsi_cmnd *SC)
 {
        unsigned long flags;
 
@@ -1685,7 +1676,7 @@ ips_alloc_passthru_buffer(ips_ha_t * ha, int length)
 /*                                                                          */
 /****************************************************************************/
 static int
-ips_make_passthru(ips_ha_t * ha, Scsi_Cmnd * SC, ips_scb_t * scb, int intr)
+ips_make_passthru(ips_ha_t *ha, struct scsi_cmnd *SC, ips_scb_t *scb, int intr)
 {
        ips_passthru_t *pt;
        int length = 0;
@@ -2734,9 +2725,9 @@ static void
 ips_next(ips_ha_t * ha, int intr)
 {
        ips_scb_t *scb;
-       Scsi_Cmnd *SC;
-       Scsi_Cmnd *p;
-       Scsi_Cmnd *q;
+       struct scsi_cmnd *SC;
+       struct scsi_cmnd *p;
+       struct scsi_cmnd *q;
        ips_copp_wait_item_t *item;
        int ret;
        unsigned long cpu_flags = 0;
@@ -2847,7 +2838,7 @@ ips_next(ips_ha_t * ha, int intr)
                        dcdb_active[scmd_channel(p) -
                                    1] & (1 << scmd_id(p)))) {
                        ips_freescb(ha, scb);
-                       p = (Scsi_Cmnd *) p->host_scribble;
+                       p = (struct scsi_cmnd *) p->host_scribble;
                        continue;
                }
 
@@ -2962,7 +2953,7 @@ ips_next(ips_ha_t * ha, int intr)
                        break;
                }               /* end case */
 
-               p = (Scsi_Cmnd *) p->host_scribble;
+               p = (struct scsi_cmnd *) p->host_scribble;
 
        }                       /* end while */
 
@@ -3090,8 +3081,7 @@ ips_removeq_scb(ips_scb_queue_t * queue, ips_scb_t * item)
 /* ASSUMED to be called from within the HA lock                             */
 /*                                                                          */
 /****************************************************************************/
-static void
-ips_putq_wait_tail(ips_wait_queue_t * queue, Scsi_Cmnd * item)
+static void ips_putq_wait_tail(ips_wait_queue_t *queue, struct scsi_cmnd *item)
 {
        METHOD_TRACE("ips_putq_wait_tail", 1);
 
@@ -3122,10 +3112,9 @@ ips_putq_wait_tail(ips_wait_queue_t * queue, Scsi_Cmnd * item)
 /* ASSUMED to be called from within the HA lock                             */
 /*                                                                          */
 /****************************************************************************/
-static Scsi_Cmnd *
-ips_removeq_wait_head(ips_wait_queue_t * queue)
+static struct scsi_cmnd *ips_removeq_wait_head(ips_wait_queue_t *queue)
 {
-       Scsi_Cmnd *item;
+       struct scsi_cmnd *item;
 
        METHOD_TRACE("ips_removeq_wait_head", 1);
 
@@ -3135,7 +3124,7 @@ ips_removeq_wait_head(ips_wait_queue_t * queue)
                return (NULL);
        }
 
-       queue->head = (Scsi_Cmnd *) item->host_scribble;
+       queue->head = (struct scsi_cmnd *) item->host_scribble;
        item->host_scribble = NULL;
 
        if (queue->tail == item)
@@ -3157,10 +3146,10 @@ ips_removeq_wait_head(ips_wait_queue_t * queue)
 /* ASSUMED to be called from within the HA lock                             */
 /*                                                                          */
 /****************************************************************************/
-static Scsi_Cmnd *
-ips_removeq_wait(ips_wait_queue_t * queue, Scsi_Cmnd * item)
+static struct scsi_cmnd *ips_removeq_wait(ips_wait_queue_t *queue,
+                                         struct scsi_cmnd *item)
 {
-       Scsi_Cmnd *p;
+       struct scsi_cmnd *p;
 
        METHOD_TRACE("ips_removeq_wait", 1);
 
@@ -3173,8 +3162,8 @@ ips_removeq_wait(ips_wait_queue_t * queue, Scsi_Cmnd * item)
 
        p = queue->head;
 
-       while ((p) && (item != (Scsi_Cmnd *) p->host_scribble))
-               p = (Scsi_Cmnd *) p->host_scribble;
+       while ((p) && (item != (struct scsi_cmnd *) p->host_scribble))
+               p = (struct scsi_cmnd *) p->host_scribble;
 
        if (p) {
                /* found a match */
@@ -3659,11 +3648,10 @@ ips_send_wait(ips_ha_t * ha, ips_scb_t * scb, int timeout, int intr)
 /* Routine Name: ips_scmd_buf_write                                         */
 /*                                                                          */
 /* Routine Description:                                                     */
-/*  Write data to Scsi_Cmnd request_buffer at proper offsets                */
+/*  Write data to struct scsi_cmnd request_buffer at proper offsets        */
 /****************************************************************************/
 static void
-ips_scmd_buf_write(Scsi_Cmnd * scmd, void *data, unsigned
-                  int count)
+ips_scmd_buf_write(struct scsi_cmnd *scmd, void *data, unsigned int count)
 {
        if (scmd->use_sg) {
                int i;
@@ -3698,11 +3686,10 @@ ips_scmd_buf_write(Scsi_Cmnd * scmd, void *data, unsigned
 /* Routine Name: ips_scmd_buf_read                                          */
 /*                                                                          */
 /* Routine Description:                                                     */
-/*  Copy data from a Scsi_Cmnd to a new, linear buffer                      */
+/*  Copy data from a struct scsi_cmnd to a new, linear buffer              */
 /****************************************************************************/
 static void
-ips_scmd_buf_read(Scsi_Cmnd * scmd, void *data, unsigned
-                 int count)
+ips_scmd_buf_read(struct scsi_cmnd *scmd, void *data, unsigned int count)
 {
        if (scmd->use_sg) {
                int i;
@@ -4363,7 +4350,7 @@ ips_rdcap(ips_ha_t * ha, ips_scb_t * scb)
 
        METHOD_TRACE("ips_rdcap", 1);
 
-       if (scb->scsi_cmd->bufflen < 8)
+       if (scb->scsi_cmd->request_bufflen < 8)
                return (0);
 
        cap.lba =
@@ -5014,7 +5001,7 @@ ips_init_copperhead(ips_ha_t * ha)
                                break;
 
                        /* Delay for 1 Second */
-                       msleep(IPS_ONE_SEC);
+                       MDELAY(IPS_ONE_SEC);
                }
 
                if (j >= 45)
@@ -5040,7 +5027,7 @@ ips_init_copperhead(ips_ha_t * ha)
                                break;
 
                        /* Delay for 1 Second */
-                       msleep(IPS_ONE_SEC);
+                       MDELAY(IPS_ONE_SEC);
                }
 
                if (j >= 240)
@@ -5058,7 +5045,7 @@ ips_init_copperhead(ips_ha_t * ha)
                        break;
 
                /* Delay for 1 Second */
-               msleep(IPS_ONE_SEC);
+               MDELAY(IPS_ONE_SEC);
        }
 
        if (i >= 240)
@@ -5108,7 +5095,7 @@ ips_init_copperhead_memio(ips_ha_t * ha)
                                break;
 
                        /* Delay for 1 Second */
-                       msleep(IPS_ONE_SEC);
+                       MDELAY(IPS_ONE_SEC);
                }
 
                if (j >= 45)
@@ -5134,7 +5121,7 @@ ips_init_copperhead_memio(ips_ha_t * ha)
                                break;
 
                        /* Delay for 1 Second */
-                       msleep(IPS_ONE_SEC);
+                       MDELAY(IPS_ONE_SEC);
                }
 
                if (j >= 240)
@@ -5152,7 +5139,7 @@ ips_init_copperhead_memio(ips_ha_t * ha)
                        break;
 
                /* Delay for 1 Second */
-               msleep(IPS_ONE_SEC);
+               MDELAY(IPS_ONE_SEC);
        }
 
        if (i >= 240)
@@ -5204,7 +5191,7 @@ ips_init_morpheus(ips_ha_t * ha)
                        break;
 
                /* Delay for 1 Second */
-               msleep(IPS_ONE_SEC);
+               MDELAY(IPS_ONE_SEC);
        }
 
        if (i >= 45) {
@@ -5230,7 +5217,7 @@ ips_init_morpheus(ips_ha_t * ha)
                        if (Post != 0x4F00)
                                break;
                        /* Delay for 1 Second */
-                       msleep(IPS_ONE_SEC);
+                       MDELAY(IPS_ONE_SEC);
                }
 
                if (i >= 120) {
@@ -5260,7 +5247,7 @@ ips_init_morpheus(ips_ha_t * ha)
                        break;
 
                /* Delay for 1 Second */
-               msleep(IPS_ONE_SEC);
+               MDELAY(IPS_ONE_SEC);
        }
 
        if (i >= 240) {
@@ -5320,12 +5307,12 @@ ips_reset_copperhead(ips_ha_t * ha)
                outb(IPS_BIT_RST, ha->io_addr + IPS_REG_SCPR);
 
                /* Delay for 1 Second */
-               msleep(IPS_ONE_SEC);
+               MDELAY(IPS_ONE_SEC);
 
                outb(0, ha->io_addr + IPS_REG_SCPR);
 
                /* Delay for 1 Second */
-               msleep(IPS_ONE_SEC);
+               MDELAY(IPS_ONE_SEC);
 
                if ((*ha->func.init) (ha))
                        break;
@@ -5365,12 +5352,12 @@ ips_reset_copperhead_memio(ips_ha_t * ha)
                writeb(IPS_BIT_RST, ha->mem_ptr + IPS_REG_SCPR);
 
                /* Delay for 1 Second */
-               msleep(IPS_ONE_SEC);
+               MDELAY(IPS_ONE_SEC);
 
                writeb(0, ha->mem_ptr + IPS_REG_SCPR);
 
                /* Delay for 1 Second */
-               msleep(IPS_ONE_SEC);
+               MDELAY(IPS_ONE_SEC);
 
                if ((*ha->func.init) (ha))
                        break;
@@ -5411,7 +5398,7 @@ ips_reset_morpheus(ips_ha_t * ha)
                writel(0x80000000, ha->mem_ptr + IPS_REG_I960_IDR);
 
                /* Delay for 5 Seconds */
-               msleep(5 * IPS_ONE_SEC);
+               MDELAY(5 * IPS_ONE_SEC);
 
                /* Do a PCI config read to wait for adapter */
                pci_read_config_byte(ha->pcidev, 4, &junk);
@@ -6437,7 +6424,7 @@ ips_erase_bios(ips_ha_t * ha)
                /* VPP failure */
                return (1);
 
-       /* check for succesful flash */
+       /* check for successful flash */
        if (status & 0x30)
                /* sequence error */
                return (1);
@@ -6549,7 +6536,7 @@ ips_erase_bios_memio(ips_ha_t * ha)
                /* VPP failure */
                return (1);
 
-       /* check for succesful flash */
+       /* check for successful flash */
        if (status & 0x30)
                /* sequence error */
                return (1);
@@ -7007,7 +6994,7 @@ ips_register_scsi(int index)
        memcpy(ha, oldha, sizeof (ips_ha_t));
        free_irq(oldha->irq, oldha);
        /* Install the interrupt handler with the new ha */
-       if (request_irq(ha->irq, do_ipsintr, SA_SHIRQ, ips_name, ha)) {
+       if (request_irq(ha->irq, do_ipsintr, IRQF_SHARED, ips_name, ha)) {
                IPS_PRINTK(KERN_WARNING, ha->pcidev,
                           "Unable to install interrupt handler\n");
                scsi_host_put(sh);
@@ -7078,7 +7065,7 @@ ips_remove_device(struct pci_dev *pci_dev)
 static int __init
 ips_module_init(void)
 {
-       if (pci_module_init(&ips_pci_driver) < 0)
+       if (pci_register_driver(&ips_pci_driver) < 0)
                return -ENODEV;
        ips_driver_template.module = THIS_MODULE;
        ips_order_controllers();
@@ -7284,10 +7271,10 @@ ips_init_phase1(struct pci_dev *pci_dev, int *indexPtr)
         * are guaranteed to be < 4G.
         */
        if (IPS_ENABLE_DMA64 && IPS_HAS_ENH_SGLIST(ha) &&
-           !pci_set_dma_mask(ha->pcidev, 0xffffffffffffffffULL)) {
+           !pci_set_dma_mask(ha->pcidev, DMA_64BIT_MASK)) {
                (ha)->flags |= IPS_HA_ENH_SG;
        } else {
-               if (pci_set_dma_mask(ha->pcidev, 0xffffffffULL) != 0) {
+               if (pci_set_dma_mask(ha->pcidev, DMA_32BIT_MASK) != 0) {
                        printk(KERN_WARNING "Unable to set DMA Mask\n");
                        return ips_abort_init(ha, index);
                }
@@ -7419,7 +7406,7 @@ ips_init_phase2(int index)
        }
 
        /* Install the interrupt handler */
-       if (request_irq(ha->irq, do_ipsintr, SA_SHIRQ, ips_name, ha)) {
+       if (request_irq(ha->irq, do_ipsintr, IRQF_SHARED, ips_name, ha)) {
                IPS_PRINTK(KERN_WARNING, ha->pcidev,
                           "Unable to install interrupt handler\n");
                return ips_abort_init(ha, index);