[SCSI] ipr: Driver version to 2.3.2
[safe/jmp/linux-2.6] / drivers / scsi / 53c7xx.c
index 7894b8e..93b41f4 100644 (file)
 
 #include <linux/module.h>
 
-#include <linux/config.h>
 
 #include <linux/types.h>
 #include <asm/setup.h>
@@ -324,7 +323,7 @@ static int shutdown (struct Scsi_Host *host);
 static void abnormal_finished (struct NCR53c7x0_cmd *cmd, int result);
 static int disable (struct Scsi_Host *host);
 static int NCR53c7xx_run_tests (struct Scsi_Host *host);
-static irqreturn_t NCR53c7x0_intr(int irq, void *dev_id, struct pt_regs * regs);
+static irqreturn_t NCR53c7x0_intr(int irq, void *dev_id);
 static void NCR53c7x0_intfly (struct Scsi_Host *host);
 static int ncr_halt (struct Scsi_Host *host);
 static void intr_phase_mismatch (struct Scsi_Host *host, struct NCR53c7x0_cmd 
@@ -361,7 +360,7 @@ int CmdPageStart = (0 - Ent_dsa_zero - sizeof(struct NCR53c7x0_cmd)) & 0xff;
 static char *setup_strings[] =
        {"","","","","","","",""};
 
-#define MAX_SETUP_STRINGS (sizeof(setup_strings) / sizeof(char *))
+#define MAX_SETUP_STRINGS ARRAY_SIZE(setup_strings)
 #define SETUP_BUFFER_SIZE 200
 static char setup_buffer[SETUP_BUFFER_SIZE];
 static char setup_used[MAX_SETUP_STRINGS];
@@ -709,7 +708,7 @@ request_synchronous (int host, int target) {
        printk (KERN_ALERT "target %d is host ID\n", target);
        return -1;
     } 
-    else if (target > h->max_id) {
+    else if (target >= h->max_id) {
        printk (KERN_ALERT "target %d exceeds maximum of %d\n", target,
            h->max_id);
        return -1;
@@ -1071,7 +1070,7 @@ NCR53c7x0_init (struct Scsi_Host *host) {
 
     NCR53c7x0_driver_init (host);
 
-    if (request_irq(host->irq, NCR53c7x0_intr, SA_SHIRQ, "53c7xx", host))
+    if (request_irq(host->irq, NCR53c7x0_intr, IRQF_SHARED, "53c7xx", host))
     {
        printk("scsi%d : IRQ%d not free, detaching\n",
                host->host_no, host->irq);
@@ -2190,15 +2189,15 @@ static const struct {
  */
 
 
-static void 
+static void
 synchronous (struct Scsi_Host *host, int target, char *msg) {
     struct NCR53c7x0_hostdata *hostdata = (struct NCR53c7x0_hostdata *)
        host->hostdata[0];
     int desire, divisor, i, limit;
     unsigned char scntl3, sxfer;
 /* The diagnostic message fits on one line, even with max. width integers */
-    char buf[80];      
-   
+    char buf[80];
+
 /* Desired transfer clock in Hz */
     desire = 1000000000L / (msg[3] * 4);
 /* Scale the available SCSI clock by 10 so we get tenths */
@@ -2209,14 +2208,14 @@ synchronous (struct Scsi_Host *host, int target, char *msg) {
        msg[4] = 8;
 
     if (hostdata->options & OPTION_DEBUG_SDTR)
-       printk("scsi%d : optimal synchronous divisor of %d.%01d\n", 
+       printk("scsi%d : optimal synchronous divisor of %d.%01d\n",
            host->host_no, divisor / 10, divisor % 10);
 
-    limit = (sizeof(syncs) / sizeof(syncs[0]) -1);
+    limit = ARRAY_SIZE(syncs) - 1;
     for (i = 0; (i < limit) && (divisor > syncs[i].div); ++i);
 
     if (hostdata->options & OPTION_DEBUG_SDTR)
-       printk("scsi%d : selected synchronous divisor of %d.%01d\n", 
+       printk("scsi%d : selected synchronous divisor of %d.%01d\n",
            host->host_no, syncs[i].div / 10, syncs[i].div % 10);
 
     msg[3] = ((1000000000L / hostdata->scsi_clock) * syncs[i].div / 10 / 4);
@@ -3100,7 +3099,6 @@ allocate_cmd (Scsi_Cmnd *cmd) {
         real = get_zeroed_page(GFP_ATOMIC);
         if (real == 0)
                return NULL;
-        memset((void *)real, 0, 4096);
         cache_push(virt_to_phys((void *)real), 4096);
         cache_clear(virt_to_phys((void *)real), 4096);
         kernel_set_cachemode((void *)real, 4096, IOMAP_NOCACHE_SER);
@@ -3452,12 +3450,12 @@ create_cmd (Scsi_Cmnd *cmd) {
     for (i = 0; cmd->use_sg ? (i < cmd->use_sg) : !i; cmd_datain += 4, 
        cmd_dataout += 4, ++i) {
        u32 vbuf = cmd->use_sg
-           ? (u32)page_address(((struct scatterlist *)cmd->buffer)[i].page)+
-             ((struct scatterlist *)cmd->buffer)[i].offset
+           ? (u32)page_address(((struct scatterlist *)cmd->request_buffer)[i].page)+
+             ((struct scatterlist *)cmd->request_buffer)[i].offset
            : (u32)(cmd->request_buffer);
        u32 bbuf = virt_to_bus((void *)vbuf);
        u32 count = cmd->use_sg ?
-           ((struct scatterlist *)cmd->buffer)[i].length :
+           ((struct scatterlist *)cmd->request_buffer)[i].length :
            cmd->request_bufflen;
 
        /*
@@ -3622,7 +3620,7 @@ NCR53c7xx_queue_command (Scsi_Cmnd *cmd, void (* done)(Scsi_Cmnd *)) {
 #ifdef LINUX_1_2
        || cmd->device->id > 7
 #else
-       || cmd->device->id > host->max_id
+       || cmd->device->id >= host->max_id
 #endif
        || cmd->device->id == host->this_id
        || hostdata->state == STATE_DISABLED) {
@@ -4228,12 +4226,12 @@ restart:
 }
 
 /*
- * Function : static irqreturn_t NCR53c7x0_intr (int irq, void *dev_id, struct pt_regs * regs)
+ * Function : static irqreturn_t NCR53c7x0_intr (int irq, void *dev_id)
  *
  * Purpose : handle NCR53c7x0 interrupts for all NCR devices sharing
  *     the same IRQ line.  
  * 
- * Inputs : Since we're using the SA_INTERRUPT interrupt handler
+ * Inputs : Since we're using the IRQF_DISABLED interrupt handler
  *     semantics, irq indicates the interrupt which invoked 
  *     this handler.  
  *
@@ -4242,7 +4240,7 @@ restart:
  */
 
 static irqreturn_t
-NCR53c7x0_intr (int irq, void *dev_id, struct pt_regs * regs)
+NCR53c7x0_intr (int irq, void *dev_id)
 {
     NCR53c7x0_local_declare();
     struct Scsi_Host *host;                    /* Host we are looking at */
@@ -4401,7 +4399,7 @@ abort_connected (struct Scsi_Host *host) {
  * account the current synchronous offset) 
  */
 
-    sstat = (NCR53c8x0_read8 (SSTAT2_REG);
+    sstat = NCR53c8x0_read8 (SSTAT2_REG);
     offset = OFFSET (sstat & SSTAT2_FF_MASK) >> SSTAT2_FF_SHIFT;
     phase = sstat & SSTAT2_PHASE_MASK;
 
@@ -5418,13 +5416,13 @@ insn_to_offset (Scsi_Cmnd *cmd, u32 *insn) {
 
            if ((buffers = cmd->use_sg)) {
                for (offset = 0, 
-                       segment = (struct scatterlist *) cmd->buffer;
+                       segment = (struct scatterlist *) cmd->request_buffer;
                     buffers && !((found = ((ptr >= (char *)page_address(segment->page)+segment->offset) && 
                            (ptr < ((char *)page_address(segment->page)+segment->offset+segment->length)))));
                     --buffers, offset += segment->length, ++segment)
 #if 0
                    printk("scsi%d: comparing 0x%p to 0x%p\n", 
-                       cmd->device->host->host_no, saved, page_address(segment->page+segment->offset);
+                       cmd->device->host->host_no, saved, page_address(segment->page+segment->offset));
 #else
                    ;
 #endif