Merge to Fedora kernel-2.6.18-1.2224_FC5 patched with stable patch-2.6.18.1-vs2.0...
[linux-2.6.git] / drivers / scsi / 53c7xx.c
index 464c261..acf2927 100644 (file)
 
 #include <linux/module.h>
 
-#include <linux/config.h>
 
 #include <linux/types.h>
 #include <asm/setup.h>
 #endif
 
 #include "scsi.h"
-#include "hosts.h"
+#include <scsi/scsi_dbg.h>
+#include <scsi/scsi_host.h>
+#include <scsi/scsi_transport_spi.h>
 #include "53c7xx.h"
 #include <linux/stat.h>
 #include <linux/stddef.h>
@@ -342,7 +343,7 @@ static void NCR53c7x0_soft_reset (struct Scsi_Host *host);
 /* Size of event list (per host adapter) */
 static int track_events = 0;
 static struct Scsi_Host *first_host = NULL;    /* Head of list of NCR boards */
-static Scsi_Host_Template *the_template = NULL;        
+static struct scsi_host_template *the_template = NULL;
 
 /* NCR53c710 script handling code */
 
@@ -359,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];
@@ -707,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;
@@ -1069,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);
@@ -1102,7 +1103,7 @@ NCR53c7x0_init (struct Scsi_Host *host) {
 }
 
 /* 
- * Function : int ncr53c7xx_init(Scsi_Host_Template *tpnt, int board, int chip,
+ * Function : int ncr53c7xx_init(struct scsi_host_template *tpnt, int board, int chip,
  *     unsigned long base, int io_port, int irq, int dma, long long options,
  *     int clock);
  *
@@ -1117,7 +1118,7 @@ NCR53c7x0_init (struct Scsi_Host *host) {
  */
 
 int 
-ncr53c7xx_init (Scsi_Host_Template *tpnt, int board, int chip,
+ncr53c7xx_init (struct scsi_host_template *tpnt, int board, int chip,
     unsigned long base, int io_port, int irq, int dma, 
     long long options, int clock)
 {
@@ -1721,9 +1722,9 @@ NCR53c7xx_run_tests (struct Scsi_Host *host) {
                printk ("scsi%d : test 2 INQUIRY to target %d, lun 0 : %s\n",
                    host->host_no, i, data + 8);
                printk ("scsi%d : status ", host->host_no);
-               print_status (status);
+               scsi_print_status (status);
                printk ("\nscsi%d : message ", host->host_no);
-               print_msg (&msg);
+               spi_print_msg(&msg);
                printk ("\n");
            } else if (hostdata->test_completed == 3) {
                printk("scsi%d : test 2 no connection with target %d\n",
@@ -2188,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 */
@@ -2207,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);
@@ -2312,7 +2313,7 @@ NCR53c7x0_dstat_sir_intr (struct Scsi_Host *host, struct
            printk ("scsi%d : received message", host->host_no);
            if (c) 
                printk (" from target %d lun %d ", c->device->id, c->device->lun);
-           print_msg ((unsigned char *) hostdata->msg_buf);
+           spi_print_msg((unsigned char *) hostdata->msg_buf);
            printk("\n");
        }
        
@@ -3204,7 +3205,7 @@ create_cmd (Scsi_Cmnd *cmd) {
     case WRITE_10:
 #if 0
        printk("scsi%d : command is ", host->host_no);
-       print_command(cmd->cmnd);
+       __scsi_print_command(cmd->cmnd);
 #endif
 #if 0
        printk ("scsi%d : %d scatter/gather segments\n", host->host_no,
@@ -3232,7 +3233,7 @@ create_cmd (Scsi_Cmnd *cmd) {
      */
     default:
        printk("scsi%d : datain+dataout for command ", host->host_no);
-       print_command(cmd->cmnd);
+       __scsi_print_command(cmd->cmnd);
        datain = dataout = 2 * (cmd->use_sg ? cmd->use_sg : 1) + 3;
     }
 
@@ -3450,12 +3451,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;
 
        /*
@@ -3620,7 +3621,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) {
@@ -3938,7 +3939,7 @@ intr_scsi (struct Scsi_Host *host, struct NCR53c7x0_cmd *cmd) {
            if (cmd) {
                printk("scsi%d : target %d, lun %d, command ",
                    host->host_no, cmd->cmd->device->id, cmd->cmd->device->lun);
-               print_command (cmd->cmd->cmnd);
+               __scsi_print_command (cmd->cmd->cmnd);
                printk("scsi%d : dsp = 0x%x (virt 0x%p)\n", host->host_no,
                    NCR53c7x0_read32(DSP_REG),
                    bus_to_virt(NCR53c7x0_read32(DSP_REG)));
@@ -4208,7 +4209,7 @@ restart:
        if (hostdata->options & OPTION_DEBUG_INTR) {
            printk ("scsi%d : command complete : pid %lu, id %d,lun %d result 0x%x ", 
                  host->host_no, tmp->pid, tmp->device->id, tmp->device->lun, tmp->result);
-           print_command (tmp->cmnd);
+           __scsi_print_command (tmp->cmnd);
        }
 
        tmp->scsi_done(tmp);
@@ -4231,7 +4232,7 @@ restart:
  * 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.  
  *
@@ -4297,7 +4298,7 @@ NCR53c7x0_intr (int irq, void *dev_id, struct pt_regs * regs)
                printk("scsi%d : interrupt for pid %lu, id %d, lun %d ", 
                    host->host_no, cmd->cmd->pid, (int) cmd->cmd->device->id,
                    (int) cmd->cmd->device->lun);
-               print_command (cmd->cmd->cmnd);
+               __scsi_print_command (cmd->cmd->cmnd);
            } else {
                printk("scsi%d : no active command\n", host->host_no);
            }
@@ -5416,7 +5417,7 @@ 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)
@@ -5539,7 +5540,7 @@ print_dsa (struct Scsi_Host *host, u32 *dsa, const char *prefix) {
            i > 0 && !check_address ((unsigned long) ptr, 1);
            ptr += len, i -= len) {
            printk("               ");
-           len = print_msg (ptr);
+           len = spi_print_msg(ptr);
            printk("\n");
            if (!len)
                break;
@@ -5554,7 +5555,7 @@ print_dsa (struct Scsi_Host *host, u32 *dsa, const char *prefix) {
     if (cmd) {
        printk("               result = 0x%x, target = %d, lun = %d, cmd = ",
            cmd->result, cmd->device->id, cmd->device->lun);
-       print_command(cmd->cmnd);
+       __scsi_print_command(cmd->cmnd);
     } else
        printk("\n");
     printk("        + %d : dsa_next = 0x%x\n", hostdata->dsa_next,
@@ -6028,7 +6029,7 @@ dump_events (struct Scsi_Host *host, int count) {
                    virt_to_bus(event.dsa), event.dsa);
            if (event.pid != -1) {
                printk ("         event for pid %ld ", event.pid);
-               print_command (event.cmnd);
+               __scsi_print_command (event.cmnd);
            }
        }
     }
@@ -6089,8 +6090,8 @@ NCR53c7x0_release(struct Scsi_Host *host) {
     if (hostdata->num_cmds)
        printk ("scsi%d : leaked %d NCR53c7x0_cmd structures\n",
            host->host_no, hostdata->num_cmds);
-    if (hostdata->events) 
-       vfree ((void *)hostdata->events);
+
+    vfree(hostdata->events);
 
     /* XXX This assumes default cache mode to be IOMAP_FULL_CACHING, which
      * XXX may be invalid (CONFIG_060_WRITETHROUGH)