]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/scsi/ips.c
[SCSI] sg: remove unnecessary check
[linux-2.6-omap-h63xx.git] / drivers / scsi / ips.c
index 5353b28b29399c40655075829e9cbcc8b7b42b8d..84f4f5d06f9d0a5b6dcb1a604d04047a5db0ccc1 100644 (file)
 #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>
@@ -218,19 +211,6 @@ module_param(ips, charp, 0);
 #warning "This driver has only been tested on the x86/ia64/x86_64 platforms"
 #endif
 
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,0)
-#include <linux/blk.h>
-#include "sd.h"
-#define IPS_LOCK_SAVE(lock,flags) spin_lock_irqsave(&io_request_lock,flags)
-#define IPS_UNLOCK_RESTORE(lock,flags) spin_unlock_irqrestore(&io_request_lock,flags)
-#ifndef __devexit_p
-#define __devexit_p(x) x
-#endif
-#else
-#define IPS_LOCK_SAVE(lock,flags) do{spin_lock(lock);(void)flags;}while(0)
-#define IPS_UNLOCK_RESTORE(lock,flags) do{spin_unlock(lock);(void)flags;}while(0)
-#endif
-
 #define IPS_DMA_DIR(scb) ((!scb->scsi_cmd || ips_is_passthru(scb->scsi_cmd) || \
                          DMA_NONE == scb->scsi_cmd->sc_data_direction) ? \
                          PCI_DMA_BIDIRECTIONAL : \
@@ -251,11 +231,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);
@@ -326,24 +306,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);
@@ -386,24 +368,13 @@ static struct scsi_host_template ips_driver_template = {
        .eh_abort_handler       = ips_eh_abort,
        .eh_host_reset_handler  = ips_eh_reset,
        .proc_name              = "ips",
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
        .proc_info              = ips_proc_info,
        .slave_configure        = ips_slave_configure,
-#else
-       .proc_info              = ips_proc24_info,
-       .select_queue_depths    = ips_select_queue_depth,
-#endif
        .bios_param             = ips_biosparam,
        .this_id                = -1,
        .sg_tablesize           = IPS_MAX_SG,
        .cmd_per_lun            = 3,
        .use_clustering         = ENABLE_CLUSTERING,
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-       .use_new_eh_code        = 1,
-#endif
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,20)  &&  LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-    .highmem_io          = 1,   
-#endif
 };
 
 
@@ -736,7 +707,7 @@ ips_release(struct Scsi_Host *sh)
        /* free IRQ */
        free_irq(ha->irq, ha);
 
-       IPS_REMOVE_HOST(sh);
+       scsi_remove_host(sh);
        scsi_host_put(sh);
 
        ips_released_controllers++;
@@ -813,13 +784,11 @@ 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;
        int ret;
-       unsigned long cpu_flags;
        struct Scsi_Host *host;
 
        METHOD_TRACE("ips_eh_abort", 1);
@@ -836,7 +805,7 @@ ips_eh_abort(Scsi_Cmnd * SC)
        if (!ha->active)
                return (FAILED);
 
-       IPS_LOCK_SAVE(host->host_lock, cpu_flags);
+       spin_lock(host->host_lock);
 
        /* See if the command is on the copp queue */
        item = ha->copp_waitlist.head;
@@ -857,7 +826,7 @@ ips_eh_abort(Scsi_Cmnd * SC)
                ret = (FAILED);
        }
 
-       IPS_UNLOCK_RESTORE(host->host_lock, cpu_flags);
+       spin_unlock(host->host_lock);
        return ret;
 }
 
@@ -872,8 +841,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;
@@ -969,7 +937,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");
@@ -998,7 +966,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");
@@ -1060,8 +1028,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;
 
@@ -1084,8 +1051,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;
@@ -1185,18 +1151,10 @@ ips_queue(Scsi_Cmnd * SC, void (*done) (Scsi_Cmnd *))
 /*   Set bios geometry for the controller                                   */
 /*                                                                          */
 /****************************************************************************/
-static int
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-ips_biosparam(Disk * disk, kdev_t dev, int geom[])
-{
-       ips_ha_t *ha = (ips_ha_t *) disk->device->host->hostdata;
-       unsigned long capacity = disk->capacity;
-#else
-ips_biosparam(struct scsi_device *sdev, struct block_device *bdev,
-             sector_t capacity, int geom[])
+static int ips_biosparam(struct scsi_device *sdev, struct block_device *bdev,
+                        sector_t capacity, int geom[])
 {
        ips_ha_t *ha = (ips_ha_t *) sdev->host->hostdata;
-#endif
        int heads;
        int sectors;
        int cylinders;
@@ -1234,70 +1192,6 @@ ips_biosparam(struct scsi_device *sdev, struct block_device *bdev,
        return (0);
 }
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-
-/* ips_proc24_info is a wrapper around ips_proc_info *
- * for compatibility with the 2.4 scsi parameters    */
-static int
-ips_proc24_info(char *buffer, char **start, off_t offset, int length,
-                             int hostno, int func)
-{
-       int i;
-
-       for (i = 0; i < ips_next_controller; i++) {
-               if (ips_sh[i] && ips_sh[i]->host_no == hostno) {
-                       return ips_proc_info(ips_sh[i], buffer, start,
-                                            offset, length, func);
-               }
-       }
-       return -EINVAL; 
-}
-
-/****************************************************************************/
-/*                                                                          */
-/* Routine Name: ips_select_queue_depth                                     */
-/*                                                                          */
-/* Routine Description:                                                     */
-/*                                                                          */
-/*   Select queue depths for the devices on the contoller                   */
-/*                                                                          */
-/****************************************************************************/
-static void
-ips_select_queue_depth(struct Scsi_Host *host, struct scsi_device * scsi_devs)
-{
-       struct scsi_device *device;
-       ips_ha_t *ha;
-       int count = 0;
-       int min;
-
-       ha = IPS_HA(host);
-       min = ha->max_cmds / 4;
-
-       for (device = scsi_devs; device; device = device->next) {
-               if (device->host == host) {
-                       if ((device->channel == 0) && (device->type == 0))
-                               count++;
-               }
-       }
-
-       for (device = scsi_devs; device; device = device->next) {
-               if (device->host == host) {
-                       if ((device->channel == 0) && (device->type == 0)) {
-                               device->queue_depth =
-                                   (ha->max_cmds - 1) / count;
-                               if (device->queue_depth < min)
-                                       device->queue_depth = min;
-                       } else {
-                               device->queue_depth = 2;
-                       }
-
-                       if (device->queue_depth < 2)
-                               device->queue_depth = 2;
-               }
-       }
-}
-
-#else
 /****************************************************************************/
 /*                                                                          */
 /* Routine Name: ips_slave_configure                                        */
@@ -1325,7 +1219,6 @@ ips_slave_configure(struct scsi_device * SDptr)
        SDptr->skip_ms_page_3f = 1;
        return 0;
 }
-#endif
 
 /****************************************************************************/
 /*                                                                          */
@@ -1337,10 +1230,9 @@ 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;
        struct Scsi_Host *host;
        int irqstatus;
 
@@ -1356,16 +1248,16 @@ do_ipsintr(int irq, void *dev_id, struct pt_regs * regs)
                return IRQ_HANDLED;
        }
 
-       IPS_LOCK_SAVE(host->host_lock, cpu_flags);
+       spin_lock(host->host_lock);
 
        if (!ha->active) {
-               IPS_UNLOCK_RESTORE(host->host_lock, cpu_flags);
+               spin_unlock(host->host_lock);
                return IRQ_HANDLED;
        }
 
        irqstatus = (*ha->func.intr) (ha);
 
-       IPS_UNLOCK_RESTORE(host->host_lock, cpu_flags);
+       spin_unlock(host->host_lock);
 
        /* start the next command */
        ips_next(ha, IPS_INTR_ON);
@@ -1603,8 +1495,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;
 
@@ -1686,7 +1577,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;
@@ -2735,12 +2626,11 @@ 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;
        struct Scsi_Host *host;
        METHOD_TRACE("ips_next", 1);
 
@@ -2752,7 +2642,7 @@ ips_next(ips_ha_t * ha, int intr)
         * this command won't time out
         */
        if (intr == IPS_INTR_ON)
-               IPS_LOCK_SAVE(host->host_lock, cpu_flags);
+               spin_lock(host->host_lock);
 
        if ((ha->subsys->param[3] & 0x300000)
            && (ha->scb_activelist.count == 0)) {
@@ -2779,14 +2669,14 @@ ips_next(ips_ha_t * ha, int intr)
                item = ips_removeq_copp_head(&ha->copp_waitlist);
                ha->num_ioctl++;
                if (intr == IPS_INTR_ON)
-                       IPS_UNLOCK_RESTORE(host->host_lock, cpu_flags);
+                       spin_unlock(host->host_lock);
                scb->scsi_cmd = item->scsi_cmd;
                kfree(item);
 
                ret = ips_make_passthru(ha, scb->scsi_cmd, scb, intr);
 
                if (intr == IPS_INTR_ON)
-                       IPS_LOCK_SAVE(host->host_lock, cpu_flags);
+                       spin_lock(host->host_lock);
                switch (ret) {
                case IPS_FAILURE:
                        if (scb->scsi_cmd) {
@@ -2848,7 +2738,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;
                }
 
@@ -2856,7 +2746,7 @@ ips_next(ips_ha_t * ha, int intr)
                SC = ips_removeq_wait(&ha->scb_waitlist, q);
 
                if (intr == IPS_INTR_ON)
-                       IPS_UNLOCK_RESTORE(host->host_lock, cpu_flags); /* Unlock HA after command is taken off queue */
+                       spin_unlock(host->host_lock);   /* Unlock HA after command is taken off queue */
 
                SC->result = DID_OK;
                SC->host_scribble = NULL;
@@ -2929,7 +2819,7 @@ ips_next(ips_ha_t * ha, int intr)
                        scb->dcdb.transfer_length = 0;
                }
                if (intr == IPS_INTR_ON)
-                       IPS_LOCK_SAVE(host->host_lock, cpu_flags);
+                       spin_lock(host->host_lock);
 
                ret = ips_send_cmd(ha, scb);
 
@@ -2963,12 +2853,12 @@ 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 */
 
        if (intr == IPS_INTR_ON)
-               IPS_UNLOCK_RESTORE(host->host_lock, cpu_flags);
+               spin_unlock(host->host_lock);
 }
 
 /****************************************************************************/
@@ -3091,8 +2981,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);
 
@@ -3123,10 +3012,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);
 
@@ -3136,7 +3024,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)
@@ -3158,10 +3046,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);
 
@@ -3174,8 +3062,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 */
@@ -3660,11 +3548,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;
@@ -3699,11 +3586,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;
@@ -5015,7 +4901,7 @@ ips_init_copperhead(ips_ha_t * ha)
                                break;
 
                        /* Delay for 1 Second */
-                       msleep(IPS_ONE_SEC);
+                       MDELAY(IPS_ONE_SEC);
                }
 
                if (j >= 45)
@@ -5041,7 +4927,7 @@ ips_init_copperhead(ips_ha_t * ha)
                                break;
 
                        /* Delay for 1 Second */
-                       msleep(IPS_ONE_SEC);
+                       MDELAY(IPS_ONE_SEC);
                }
 
                if (j >= 240)
@@ -5059,7 +4945,7 @@ ips_init_copperhead(ips_ha_t * ha)
                        break;
 
                /* Delay for 1 Second */
-               msleep(IPS_ONE_SEC);
+               MDELAY(IPS_ONE_SEC);
        }
 
        if (i >= 240)
@@ -5109,7 +4995,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)
@@ -5135,7 +5021,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)
@@ -5153,7 +5039,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)
@@ -5205,7 +5091,7 @@ ips_init_morpheus(ips_ha_t * ha)
                        break;
 
                /* Delay for 1 Second */
-               msleep(IPS_ONE_SEC);
+               MDELAY(IPS_ONE_SEC);
        }
 
        if (i >= 45) {
@@ -5231,7 +5117,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) {
@@ -5261,7 +5147,7 @@ ips_init_morpheus(ips_ha_t * ha)
                        break;
 
                /* Delay for 1 Second */
-               msleep(IPS_ONE_SEC);
+               MDELAY(IPS_ONE_SEC);
        }
 
        if (i >= 240) {
@@ -5321,12 +5207,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;
@@ -5366,12 +5252,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;
@@ -5412,7 +5298,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);
@@ -6438,7 +6324,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);
@@ -6550,7 +6436,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);
@@ -7008,7 +6894,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);
@@ -7018,7 +6904,6 @@ ips_register_scsi(int index)
        kfree(oldha);
        ips_sh[index] = sh;
        ips_ha[index] = ha;
-       IPS_SCSI_SET_DEVICE(sh, ha);
 
        /* Store away needed values for later use */
        sh->io_port = ha->io_addr;
@@ -7030,17 +6915,16 @@ ips_register_scsi(int index)
        sh->cmd_per_lun = sh->hostt->cmd_per_lun;
        sh->unchecked_isa_dma = sh->hostt->unchecked_isa_dma;
        sh->use_clustering = sh->hostt->use_clustering;
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,7)
        sh->max_sectors = 128;
-#endif
 
        sh->max_id = ha->ntargets;
        sh->max_lun = ha->nlun;
        sh->max_channel = ha->nbus - 1;
        sh->can_queue = ha->max_cmds - 1;
 
-       IPS_ADD_HOST(sh, NULL);
+       scsi_add_host(sh, NULL);
+       scsi_scan_host(sh);
+
        return 0;
 }
 
@@ -7079,11 +6963,11 @@ 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();
-       if (IPS_REGISTER_HOSTS(&ips_driver_template)) {
+       if (!ips_detect(&ips_driver_template)) {
                pci_unregister_driver(&ips_pci_driver);
                return -ENODEV;
        }
@@ -7101,7 +6985,6 @@ ips_module_init(void)
 static void __exit
 ips_module_exit(void)
 {
-       IPS_UNREGISTER_HOSTS(&ips_driver_template);
        pci_unregister_driver(&ips_pci_driver);
        unregister_reboot_notifier(&ips_notifier);
 }
@@ -7420,7 +7303,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);
@@ -7457,15 +7340,9 @@ ips_init_phase2(int index)
        return SUCCESS;
 }
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,9)
 MODULE_LICENSE("GPL");
-#endif
-
 MODULE_DESCRIPTION("IBM ServeRAID Adapter Driver " IPS_VER_STRING);
-
-#ifdef MODULE_VERSION
 MODULE_VERSION(IPS_VER_STRING);
-#endif
 
 
 /*