patch-2.4.14 linux/drivers/scsi/wd33c93.c

Next file: linux/drivers/scsi/wd33c93.h
Previous file: linux/drivers/scsi/u14-34f.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.13/linux/drivers/scsi/wd33c93.c linux/drivers/scsi/wd33c93.c
@@ -175,71 +175,72 @@
 
 
 
-static inline uchar read_wd33c93(wd33c93_regs *regp,uchar reg_num)
+static inline uchar read_wd33c93(const wd33c93_regs regs, uchar reg_num)
 {
-   regp->SASR = reg_num;
+   *regs.SASR = reg_num;
    mb();
-   return(regp->SCMD);
+   return(*regs.SCMD);
 }
 
 
-#define READ_AUX_STAT() (regp->SASR)
+#define READ_AUX_STAT() (*regs.SASR)
 
 
-static inline void write_wd33c93(wd33c93_regs *regp,uchar reg_num, uchar value)
+static inline void write_wd33c93(const wd33c93_regs regs, uchar reg_num,
+				 uchar value)
 {
-   regp->SASR = reg_num;
+   *regs.SASR = reg_num;
    mb();
-   regp->SCMD = value;
+   *regs.SCMD = value;
    mb();
 }
 
 
-static inline void write_wd33c93_cmd(wd33c93_regs *regp, uchar cmd)
+static inline void write_wd33c93_cmd(const wd33c93_regs regs, uchar cmd)
 {
-   regp->SASR = WD_COMMAND;
+   *regs.SASR = WD_COMMAND;
    mb();
-   regp->SCMD = cmd;
+   *regs.SCMD = cmd;
    mb();
 }
 
 
-static inline uchar read_1_byte(wd33c93_regs *regp)
+static inline uchar read_1_byte(const wd33c93_regs regs)
 {
 uchar asr;
 uchar x = 0;
 
-   write_wd33c93(regp, WD_CONTROL, CTRL_IDI | CTRL_EDI | CTRL_POLLED);
-   write_wd33c93_cmd(regp, WD_CMD_TRANS_INFO|0x80);
+   write_wd33c93(regs, WD_CONTROL, CTRL_IDI | CTRL_EDI | CTRL_POLLED);
+   write_wd33c93_cmd(regs, WD_CMD_TRANS_INFO|0x80);
    do {
       asr = READ_AUX_STAT();
       if (asr & ASR_DBR)
-         x = read_wd33c93(regp, WD_DATA);
+         x = read_wd33c93(regs, WD_DATA);
       } while (!(asr & ASR_INT));
    return x;
 }
 
 
-static void write_wd33c93_count(wd33c93_regs *regp,unsigned long value)
+static void write_wd33c93_count(const wd33c93_regs regs, unsigned long value)
 {
-   regp->SASR = WD_TRANSFER_COUNT_MSB;
+   *regs.SASR = WD_TRANSFER_COUNT_MSB;
    mb();
-   regp->SCMD = value >> 16;
-   regp->SCMD = value >> 8;
-   regp->SCMD = value;
+   *regs.SCMD = value >> 16;
+   *regs.SCMD = value >> 8;
+   *regs.SCMD = value;
    mb();
 }
 
 
-static unsigned long read_wd33c93_count(wd33c93_regs *regp)
+static unsigned long read_wd33c93_count(const wd33c93_regs regs)
 {
 unsigned long value;
 
-   regp->SASR = WD_TRANSFER_COUNT_MSB;
+   *regs.SASR = WD_TRANSFER_COUNT_MSB;
    mb();
-   value = regp->SCMD << 16;
-   value |= regp->SCMD << 8;
-   value |= regp->SCMD;
+   value = *regs.SCMD << 16;
+   value |= *regs.SCMD << 8;
+   value |= *regs.SCMD;
    mb();
    return value;
 }
@@ -423,14 +424,11 @@
  */
 static void wd33c93_execute (struct Scsi_Host *instance)
 {
-struct WD33C93_hostdata *hostdata;
-wd33c93_regs *regp;
+struct WD33C93_hostdata *hostdata = (struct WD33C93_hostdata *)instance->hostdata;
+const wd33c93_regs regs = hostdata->regs;
 Scsi_Cmnd *cmd, *prev;
 int i;
 
-   hostdata = (struct WD33C93_hostdata *)instance->hostdata;
-   regp = hostdata->regp;
-
 DB(DB_EXECUTE,printk("EX("))
 
    if (hostdata->selecting || hostdata->connected) {
@@ -479,9 +477,9 @@
     */
 
    if (is_dir_out(cmd))
-      write_wd33c93(regp, WD_DESTINATION_ID, cmd->target);
+      write_wd33c93(regs, WD_DESTINATION_ID, cmd->target);
    else
-      write_wd33c93(regp, WD_DESTINATION_ID, cmd->target | DSTID_DPD);
+      write_wd33c93(regs, WD_DESTINATION_ID, cmd->target | DSTID_DPD);
 
 /* Now we need to figure out whether or not this command is a good
  * candidate for disconnect/reselect. We guess to the best of our
@@ -537,10 +535,10 @@
 
 no:
 
-   write_wd33c93(regp, WD_SOURCE_ID, ((cmd->SCp.phase)?SRCID_ER:0));
+   write_wd33c93(regs, WD_SOURCE_ID, ((cmd->SCp.phase)?SRCID_ER:0));
 
-   write_wd33c93(regp, WD_TARGET_LUN, cmd->lun);
-   write_wd33c93(regp,WD_SYNCHRONOUS_TRANSFER,hostdata->sync_xfer[cmd->target]);
+   write_wd33c93(regs, WD_TARGET_LUN, cmd->lun);
+   write_wd33c93(regs, WD_SYNCHRONOUS_TRANSFER,hostdata->sync_xfer[cmd->target]);
    hostdata->busy[cmd->target] |= (1 << cmd->lun);
 
    if ((hostdata->level2 == L2_NONE) ||
@@ -571,8 +569,8 @@
       if (hostdata->sync_stat[cmd->target] == SS_UNSET)
             hostdata->sync_stat[cmd->target] = SS_FIRST;
       hostdata->state = S_SELECTING;
-      write_wd33c93_count(regp,0); /* guarantee a DATA_PHASE interrupt */
-      write_wd33c93_cmd(regp, WD_CMD_SEL_ATN);
+      write_wd33c93_count(regs, 0); /* guarantee a DATA_PHASE interrupt */
+      write_wd33c93_cmd(regs, WD_CMD_SEL_ATN);
       }
 
    else {
@@ -586,15 +584,15 @@
           */
 
       hostdata->connected = cmd;
-      write_wd33c93(regp, WD_COMMAND_PHASE, 0);
+      write_wd33c93(regs, WD_COMMAND_PHASE, 0);
 
    /* copy command_descriptor_block into WD chip
     * (take advantage of auto-incrementing)
     */
 
-      regp->SASR = WD_CDB_1;
+      *regs.SASR = WD_CDB_1;
       for (i=0; i<cmd->cmd_len; i++)
-         regp->SCMD = cmd->cmnd[i];
+         *regs.SCMD = cmd->cmnd[i];
 
    /* The wd33c93 only knows about Group 0, 1, and 5 commands when
     * it's doing a 'select-and-transfer'. To be safe, we write the
@@ -602,7 +600,7 @@
     * way there won't be problems with vendor-unique, audio, etc.
     */
 
-      write_wd33c93(regp, WD_OWN_ID, cmd->cmd_len);
+      write_wd33c93(regs, WD_OWN_ID, cmd->cmd_len);
 
    /* When doing a non-disconnect command with DMA, we can save
     * ourselves a DATA phase interrupt later by setting everything
@@ -612,18 +610,18 @@
       if ((cmd->SCp.phase == 0) && (hostdata->no_dma == 0)) {
          if (hostdata->dma_setup(cmd,
                      (is_dir_out(cmd))?DATA_OUT_DIR:DATA_IN_DIR))
-            write_wd33c93_count(regp,0); /* guarantee a DATA_PHASE interrupt */
+            write_wd33c93_count(regs, 0); /* guarantee a DATA_PHASE interrupt */
          else {
-            write_wd33c93_count(regp, cmd->SCp.this_residual);
-            write_wd33c93(regp,WD_CONTROL, CTRL_IDI | CTRL_EDI | CTRL_DMA);
+            write_wd33c93_count(regs, cmd->SCp.this_residual);
+            write_wd33c93(regs, WD_CONTROL, CTRL_IDI | CTRL_EDI | CTRL_DMA);
             hostdata->dma = D_DMA_RUNNING;
             }
          }
       else
-         write_wd33c93_count(regp,0); /* guarantee a DATA_PHASE interrupt */
+         write_wd33c93_count(regs, 0); /* guarantee a DATA_PHASE interrupt */
 
       hostdata->state = S_RUNNING_LEVEL2;
-      write_wd33c93_cmd(regp, WD_CMD_SEL_ATN_XFER);
+      write_wd33c93_cmd(regs, WD_CMD_SEL_ATN_XFER);
       }
 
    /*
@@ -638,28 +636,28 @@
 
 
 
-static void transfer_pio(wd33c93_regs *regp, uchar *buf, int cnt,
-                  int data_in_dir, struct WD33C93_hostdata *hostdata)
+static void transfer_pio(const wd33c93_regs regs, uchar *buf, int cnt,
+			 int data_in_dir, struct WD33C93_hostdata *hostdata)
 {
 uchar asr;
 
 DB(DB_TRANSFER,printk("(%p,%d,%s:",buf,cnt,data_in_dir?"in":"out"))
 
-   write_wd33c93(regp, WD_CONTROL, CTRL_IDI | CTRL_EDI | CTRL_POLLED);
-   write_wd33c93_count(regp,cnt);
-   write_wd33c93_cmd(regp, WD_CMD_TRANS_INFO);
+   write_wd33c93(regs, WD_CONTROL, CTRL_IDI | CTRL_EDI | CTRL_POLLED);
+   write_wd33c93_count(regs, cnt);
+   write_wd33c93_cmd(regs, WD_CMD_TRANS_INFO);
    if (data_in_dir) {
       do {
          asr = READ_AUX_STAT();
          if (asr & ASR_DBR)
-            *buf++ = read_wd33c93(regp, WD_DATA);
+            *buf++ = read_wd33c93(regs, WD_DATA);
          } while (!(asr & ASR_INT));
       }
    else {
       do {
          asr = READ_AUX_STAT();
          if (asr & ASR_DBR)
-            write_wd33c93(regp, WD_DATA, *buf++);
+            write_wd33c93(regs, WD_DATA, *buf++);
          } while (!(asr & ASR_INT));
       }
 
@@ -674,7 +672,8 @@
 
 
 
-static void transfer_bytes(wd33c93_regs *regp, Scsi_Cmnd *cmd, int data_in_dir)
+static void transfer_bytes(const wd33c93_regs regs, Scsi_Cmnd *cmd,
+			   int data_in_dir)
 {
 struct WD33C93_hostdata *hostdata;
 unsigned long length;
@@ -696,7 +695,7 @@
       cmd->SCp.ptr = cmd->SCp.buffer->address;
       }
 
-   write_wd33c93(regp,WD_SYNCHRONOUS_TRANSFER,hostdata->sync_xfer[cmd->target]);
+   write_wd33c93(regs, WD_SYNCHRONOUS_TRANSFER,hostdata->sync_xfer[cmd->target]);
 
 /* 'hostdata->no_dma' is TRUE if we don't even want to try DMA.
  * Update 'this_residual' and 'ptr' after 'transfer_pio()' returns.
@@ -714,10 +713,10 @@
 #ifdef PROC_STATISTICS
       hostdata->pio_cnt++;
 #endif
-      transfer_pio(regp, (uchar *)cmd->SCp.ptr, cmd->SCp.this_residual,
+      transfer_pio(regs, (uchar *)cmd->SCp.ptr, cmd->SCp.this_residual,
                          data_in_dir, hostdata);
       length = cmd->SCp.this_residual;
-      cmd->SCp.this_residual = read_wd33c93_count(regp);
+      cmd->SCp.this_residual = read_wd33c93_count(regs);
       cmd->SCp.ptr += (length - cmd->SCp.this_residual);
       }
 
@@ -734,17 +733,17 @@
 #ifdef PROC_STATISTICS
       hostdata->dma_cnt++;
 #endif
-      write_wd33c93(regp, WD_CONTROL, CTRL_IDI | CTRL_EDI | CTRL_DMA);
-      write_wd33c93_count(regp,cmd->SCp.this_residual);
+      write_wd33c93(regs, WD_CONTROL, CTRL_IDI | CTRL_EDI | CTRL_DMA);
+      write_wd33c93_count(regs, cmd->SCp.this_residual);
 
       if ((hostdata->level2 >= L2_DATA) ||
           (hostdata->level2 == L2_BASIC && cmd->SCp.phase == 0)) {
-         write_wd33c93(regp, WD_COMMAND_PHASE, 0x45);
-         write_wd33c93_cmd(regp, WD_CMD_SEL_ATN_XFER);
+         write_wd33c93(regs, WD_COMMAND_PHASE, 0x45);
+         write_wd33c93_cmd(regs, WD_CMD_SEL_ATN_XFER);
          hostdata->state = S_RUNNING_LEVEL2;
          }
       else
-         write_wd33c93_cmd(regp, WD_CMD_TRANS_INFO);
+         write_wd33c93_cmd(regs, WD_CMD_TRANS_INFO);
 
       hostdata->dma = D_DMA_RUNNING;
       }
@@ -754,15 +753,12 @@
 
 void wd33c93_intr (struct Scsi_Host *instance)
 {
-struct WD33C93_hostdata *hostdata;
+struct WD33C93_hostdata *hostdata = (struct WD33C93_hostdata *)instance->hostdata;
+const wd33c93_regs regs = hostdata->regs;
 Scsi_Cmnd *patch, *cmd;
-wd33c93_regs *regp;
 uchar asr, sr, phs, id, lun, *ucp, msg;
 unsigned long length, flags;
 
-   hostdata = (struct WD33C93_hostdata *)instance->hostdata;
-   regp = hostdata->regp;
-
    asr = READ_AUX_STAT();
    if (!(asr & ASR_INT) || (asr & ASR_BSY))
       return;
@@ -774,8 +770,8 @@
 #endif
 
    cmd = (Scsi_Cmnd *)hostdata->connected;   /* assume we're connected */
-   sr = read_wd33c93(regp, WD_SCSI_STATUS);  /* clear the interrupt */
-   phs = read_wd33c93(regp, WD_COMMAND_PHASE);
+   sr = read_wd33c93(regs, WD_SCSI_STATUS);  /* clear the interrupt */
+   phs = read_wd33c93(regs, WD_COMMAND_PHASE);
 
 DB(DB_INTR,printk("{%02x:%02x-",asr,sr))
 
@@ -799,7 +795,7 @@
       hostdata->dma_stop(cmd->host, cmd, 1);
       hostdata->dma = D_DMA_OFF;
       length = cmd->SCp.this_residual;
-      cmd->SCp.this_residual = read_wd33c93_count(regp);
+      cmd->SCp.this_residual = read_wd33c93_count(regs);
       cmd->SCp.ptr += (length - cmd->SCp.this_residual);
 DB(DB_TRANSFER,printk("%p/%d]",cmd->SCp.ptr,cmd->SCp.this_residual))
       }
@@ -894,7 +890,7 @@
       case CSR_UNEXP    |PHS_DATA_IN:
       case CSR_SRV_REQ  |PHS_DATA_IN:
 DB(DB_INTR,printk("IN-%d.%d",cmd->SCp.this_residual,cmd->SCp.buffers_residual))
-         transfer_bytes(regp, cmd, DATA_IN_DIR);
+         transfer_bytes(regs, cmd, DATA_IN_DIR);
          if (hostdata->state != S_RUNNING_LEVEL2)
             hostdata->state = S_CONNECTED;
          break;
@@ -904,7 +900,7 @@
       case CSR_UNEXP    |PHS_DATA_OUT:
       case CSR_SRV_REQ  |PHS_DATA_OUT:
 DB(DB_INTR,printk("OUT-%d.%d",cmd->SCp.this_residual,cmd->SCp.buffers_residual))
-         transfer_bytes(regp, cmd, DATA_OUT_DIR);
+         transfer_bytes(regs, cmd, DATA_OUT_DIR);
          if (hostdata->state != S_RUNNING_LEVEL2)
             hostdata->state = S_CONNECTED;
          break;
@@ -916,7 +912,7 @@
       case CSR_UNEXP    |PHS_COMMAND:
       case CSR_SRV_REQ  |PHS_COMMAND:
 DB(DB_INTR,printk("CMND-%02x,%ld",cmd->cmnd[0],cmd->pid))
-         transfer_pio(regp, cmd->cmnd, cmd->cmd_len, DATA_OUT_DIR, hostdata);
+         transfer_pio(regs, cmd->cmnd, cmd->cmd_len, DATA_OUT_DIR, hostdata);
          hostdata->state = S_CONNECTED;
          break;
 
@@ -926,13 +922,13 @@
       case CSR_SRV_REQ  |PHS_STATUS:
 DB(DB_INTR,printk("STATUS="))
 
-         cmd->SCp.Status = read_1_byte(regp);
+         cmd->SCp.Status = read_1_byte(regs);
 DB(DB_INTR,printk("%02x",cmd->SCp.Status))
          if (hostdata->level2 >= L2_BASIC) {
-            sr = read_wd33c93(regp, WD_SCSI_STATUS);  /* clear interrupt */
+            sr = read_wd33c93(regs, WD_SCSI_STATUS);  /* clear interrupt */
             hostdata->state = S_RUNNING_LEVEL2;
-            write_wd33c93(regp, WD_COMMAND_PHASE, 0x50);
-            write_wd33c93_cmd(regp, WD_CMD_SEL_ATN_XFER);
+            write_wd33c93(regs, WD_COMMAND_PHASE, 0x50);
+            write_wd33c93_cmd(regs, WD_CMD_SEL_ATN_XFER);
             }
          else {
             hostdata->state = S_CONNECTED;
@@ -945,8 +941,8 @@
       case CSR_SRV_REQ  |PHS_MESS_IN:
 DB(DB_INTR,printk("MSG_IN="))
 
-         msg = read_1_byte(regp);
-         sr = read_wd33c93(regp, WD_SCSI_STATUS);  /* clear interrupt */
+         msg = read_1_byte(regs);
+         sr = read_wd33c93(regs, WD_SCSI_STATUS);  /* clear interrupt */
 
          hostdata->incoming_msg[hostdata->incoming_ptr] = msg;
          if (hostdata->incoming_msg[0] == EXTENDED_MESSAGE)
@@ -959,25 +955,25 @@
 
             case COMMAND_COMPLETE:
 DB(DB_INTR,printk("CCMP-%ld",cmd->pid))
-               write_wd33c93_cmd(regp,WD_CMD_NEGATE_ACK);
+               write_wd33c93_cmd(regs, WD_CMD_NEGATE_ACK);
                hostdata->state = S_PRE_CMP_DISC;
                break;
 
             case SAVE_POINTERS:
 DB(DB_INTR,printk("SDP"))
-               write_wd33c93_cmd(regp,WD_CMD_NEGATE_ACK);
+               write_wd33c93_cmd(regs, WD_CMD_NEGATE_ACK);
                hostdata->state = S_CONNECTED;
                break;
 
             case RESTORE_POINTERS:
 DB(DB_INTR,printk("RDP"))
                if (hostdata->level2 >= L2_BASIC) {
-                  write_wd33c93(regp, WD_COMMAND_PHASE, 0x45);
-                  write_wd33c93_cmd(regp, WD_CMD_SEL_ATN_XFER);
+                  write_wd33c93(regs, WD_COMMAND_PHASE, 0x45);
+                  write_wd33c93_cmd(regs, WD_CMD_SEL_ATN_XFER);
                   hostdata->state = S_RUNNING_LEVEL2;
                   }
                else {
-                  write_wd33c93_cmd(regp, WD_CMD_NEGATE_ACK);
+                  write_wd33c93_cmd(regs, WD_CMD_NEGATE_ACK);
                   hostdata->state = S_CONNECTED;
                   }
                break;
@@ -985,7 +981,7 @@
             case DISCONNECT:
 DB(DB_INTR,printk("DIS"))
                cmd->device->disconnect = 1;
-               write_wd33c93_cmd(regp,WD_CMD_NEGATE_ACK);
+               write_wd33c93_cmd(regs, WD_CMD_NEGATE_ACK);
                hostdata->state = S_PRE_TMP_DISC;
                break;
 
@@ -996,7 +992,7 @@
 #endif
                if (hostdata->sync_stat[cmd->target] == SS_WAITING)
                   hostdata->sync_stat[cmd->target] = SS_SET;
-               write_wd33c93_cmd(regp,WD_CMD_NEGATE_ACK);
+               write_wd33c93_cmd(regs, WD_CMD_NEGATE_ACK);
                hostdata->state = S_CONNECTED;
                break;
 
@@ -1027,7 +1023,7 @@
  * specifically ask for sync transfers, we won't do any.
  */
 
-                           write_wd33c93_cmd(regp,WD_CMD_ASSERT_ATN); /* want MESS_OUT */
+                           write_wd33c93_cmd(regs, WD_CMD_ASSERT_ATN); /* want MESS_OUT */
                            hostdata->outgoing_msg[0] = EXTENDED_MESSAGE;
                            hostdata->outgoing_msg[1] = 3;
                            hostdata->outgoing_msg[2] = EXTENDED_SDTR;
@@ -1044,26 +1040,26 @@
 printk("sync_xfer=%02x",hostdata->sync_xfer[cmd->target]);
 #endif
                         hostdata->sync_stat[cmd->target] = SS_SET;
-                        write_wd33c93_cmd(regp,WD_CMD_NEGATE_ACK);
+                        write_wd33c93_cmd(regs, WD_CMD_NEGATE_ACK);
                         hostdata->state = S_CONNECTED;
                         break;
                      case EXTENDED_WDTR:
-                        write_wd33c93_cmd(regp,WD_CMD_ASSERT_ATN); /* want MESS_OUT */
+                        write_wd33c93_cmd(regs, WD_CMD_ASSERT_ATN); /* want MESS_OUT */
                         printk("sending WDTR ");
                         hostdata->outgoing_msg[0] = EXTENDED_MESSAGE;
                         hostdata->outgoing_msg[1] = 2;
                         hostdata->outgoing_msg[2] = EXTENDED_WDTR;
                         hostdata->outgoing_msg[3] = 0;   /* 8 bit transfer width */
                         hostdata->outgoing_len = 4;
-                        write_wd33c93_cmd(regp,WD_CMD_NEGATE_ACK);
+                        write_wd33c93_cmd(regs, WD_CMD_NEGATE_ACK);
                         hostdata->state = S_CONNECTED;
                         break;
                      default:
-                        write_wd33c93_cmd(regp,WD_CMD_ASSERT_ATN); /* want MESS_OUT */
+                        write_wd33c93_cmd(regs, WD_CMD_ASSERT_ATN); /* want MESS_OUT */
                         printk("Rejecting Unknown Extended Message(%02x). ",ucp[2]);
                         hostdata->outgoing_msg[0] = MESSAGE_REJECT;
                         hostdata->outgoing_len = 1;
-                        write_wd33c93_cmd(regp,WD_CMD_NEGATE_ACK);
+                        write_wd33c93_cmd(regs, WD_CMD_NEGATE_ACK);
                         hostdata->state = S_CONNECTED;
                         break;
                      }
@@ -1074,17 +1070,17 @@
 
                else {
                   hostdata->incoming_ptr++;
-                  write_wd33c93_cmd(regp,WD_CMD_NEGATE_ACK);
+                  write_wd33c93_cmd(regs, WD_CMD_NEGATE_ACK);
                   hostdata->state = S_CONNECTED;
                   }
                break;
 
             default:
                printk("Rejecting Unknown Message(%02x) ",msg);
-               write_wd33c93_cmd(regp,WD_CMD_ASSERT_ATN); /* want MESS_OUT */
+               write_wd33c93_cmd(regs, WD_CMD_ASSERT_ATN); /* want MESS_OUT */
                hostdata->outgoing_msg[0] = MESSAGE_REJECT;
                hostdata->outgoing_len = 1;
-               write_wd33c93_cmd(regp,WD_CMD_NEGATE_ACK);
+               write_wd33c93_cmd(regs, WD_CMD_NEGATE_ACK);
                hostdata->state = S_CONNECTED;
             }
          restore_flags(flags);
@@ -1099,11 +1095,11 @@
  * have been turned off for the command that just completed.
  */
 
-         write_wd33c93(regp,WD_SOURCE_ID, SRCID_ER);
+         write_wd33c93(regs, WD_SOURCE_ID, SRCID_ER);
          if (phs == 0x60) {
 DB(DB_INTR,printk("SX-DONE-%ld",cmd->pid))
             cmd->SCp.Message = COMMAND_COMPLETE;
-            lun = read_wd33c93(regp, WD_TARGET_LUN);
+            lun = read_wd33c93(regs, WD_TARGET_LUN);
 DB(DB_INTR,printk(":%d.%d",cmd->SCp.Status,lun))
             hostdata->connected = NULL;
             hostdata->busy[cmd->target] &= ~(1 << cmd->lun);
@@ -1133,8 +1129,8 @@
       case CSR_SDP:
 DB(DB_INTR,printk("SDP"))
             hostdata->state = S_RUNNING_LEVEL2;
-            write_wd33c93(regp, WD_COMMAND_PHASE, 0x41);
-            write_wd33c93_cmd(regp, WD_CMD_SEL_ATN_XFER);
+            write_wd33c93(regs, WD_COMMAND_PHASE, 0x41);
+            write_wd33c93_cmd(regs, WD_CMD_SEL_ATN_XFER);
          break;
 
 
@@ -1160,7 +1156,7 @@
             hostdata->outgoing_len = 1;
             hostdata->outgoing_msg[0] = NOP;
             }
-         transfer_pio(regp, hostdata->outgoing_msg, hostdata->outgoing_len,
+         transfer_pio(regs, hostdata->outgoing_msg, hostdata->outgoing_len,
                             DATA_OUT_DIR, hostdata);
 DB(DB_INTR,printk("%02x",hostdata->outgoing_msg[0]))
          hostdata->outgoing_len = 0;
@@ -1182,7 +1178,7 @@
  * have been turned off for the command that just completed.
  */
 
-         write_wd33c93(regp,WD_SOURCE_ID, SRCID_ER);
+         write_wd33c93(regs, WD_SOURCE_ID, SRCID_ER);
          if (cmd == NULL) {
             printk(" - Already disconnected! ");
             hostdata->state = S_UNCONNECTED;
@@ -1213,7 +1209,7 @@
  * have been turned off for the command that just completed.
  */
 
-         write_wd33c93(regp,WD_SOURCE_ID, SRCID_ER);
+         write_wd33c93(regs, WD_SOURCE_ID, SRCID_ER);
 DB(DB_INTR,printk("DISC-%ld",cmd->pid))
          if (cmd == NULL) {
             printk(" - Already disconnected! ");
@@ -1298,7 +1294,7 @@
 
    /* OK - find out which device reselected us. */
 
-         id = read_wd33c93(regp, WD_SOURCE_ID);
+         id = read_wd33c93(regs, WD_SOURCE_ID);
          id &= SRCID_MASK;
 
    /* and extract the lun from the ID message. (Note that we don't
@@ -1307,9 +1303,9 @@
     */
 
          if (sr == CSR_RESEL_AM) {
-            lun = read_wd33c93(regp, WD_DATA);
+            lun = read_wd33c93(regs, WD_DATA);
             if (hostdata->level2 < L2_RESELECT)
-               write_wd33c93_cmd(regp,WD_CMD_NEGATE_ACK);
+               write_wd33c93_cmd(regs, WD_CMD_NEGATE_ACK);
             lun &= 7;
          }
          else {
@@ -1325,12 +1321,12 @@
             }
             else {
                /* Verify this is a change to MSG_IN and read the message */
-               sr = read_wd33c93(regp, WD_SCSI_STATUS);
+               sr = read_wd33c93(regs, WD_SCSI_STATUS);
                if (sr == (CSR_ABORT   | PHS_MESS_IN) ||
                    sr == (CSR_UNEXP   | PHS_MESS_IN) ||
                    sr == (CSR_SRV_REQ | PHS_MESS_IN)) {
                   /* Got MSG_IN, grab target LUN */
-                  lun = read_1_byte(regp);
+                  lun = read_1_byte(regs);
                   /* Now we expect a 'paused with ACK asserted' int.. */
                   asr = READ_AUX_STAT();
                   if (!(asr & ASR_INT)) {
@@ -1340,12 +1336,12 @@
                         printk("wd33c93: No int after LUN on RESEL (%02x)\n",
                               asr);
                   }
-                  sr = read_wd33c93(regp, WD_SCSI_STATUS);
+                  sr = read_wd33c93(regs, WD_SCSI_STATUS);
                   if (sr != CSR_MSGIN)
                      printk("wd33c93: Not paused with ACK on RESEL (%02x)\n",
                            sr);
                   lun &= 7;
-                  write_wd33c93_cmd(regp,WD_CMD_NEGATE_ACK);
+                  write_wd33c93_cmd(regs, WD_CMD_NEGATE_ACK);
                }
                else {
                   printk("wd33c93: Not MSG_IN on reselect (%02x)\n", sr);
@@ -1386,13 +1382,13 @@
     */
 
          if (is_dir_out(cmd))
-            write_wd33c93(regp, WD_DESTINATION_ID, cmd->target);
+            write_wd33c93(regs, WD_DESTINATION_ID, cmd->target);
          else
-            write_wd33c93(regp, WD_DESTINATION_ID, cmd->target | DSTID_DPD);
+            write_wd33c93(regs, WD_DESTINATION_ID, cmd->target | DSTID_DPD);
          if (hostdata->level2 >= L2_RESELECT) {
-            write_wd33c93_count(regp, 0);  /* we want a DATA_PHASE interrupt */
-            write_wd33c93(regp, WD_COMMAND_PHASE, 0x45);
-            write_wd33c93_cmd(regp, WD_CMD_SEL_ATN_XFER);
+            write_wd33c93_count(regs, 0);  /* we want a DATA_PHASE interrupt */
+            write_wd33c93(regs, WD_COMMAND_PHASE, 0x45);
+            write_wd33c93_cmd(regs, WD_CMD_SEL_ATN_XFER);
             hostdata->state = S_RUNNING_LEVEL2;
             }
          else
@@ -1413,36 +1409,33 @@
 
 static void reset_wd33c93(struct Scsi_Host *instance)
 {
-struct WD33C93_hostdata *hostdata;
-wd33c93_regs *regp;
+struct WD33C93_hostdata *hostdata = (struct WD33C93_hostdata *)instance->hostdata;
+const wd33c93_regs regs = hostdata->regs;
 uchar sr;
 
-   hostdata = (struct WD33C93_hostdata *)instance->hostdata;
-   regp = hostdata->regp;
-
-   write_wd33c93(regp, WD_OWN_ID, OWNID_EAF | OWNID_RAF |
+   write_wd33c93(regs, WD_OWN_ID, OWNID_EAF | OWNID_RAF |
                  instance->this_id | hostdata->clock_freq);
-   write_wd33c93(regp, WD_CONTROL, CTRL_IDI | CTRL_EDI | CTRL_POLLED);
-   write_wd33c93(regp, WD_SYNCHRONOUS_TRANSFER,
+   write_wd33c93(regs, WD_CONTROL, CTRL_IDI | CTRL_EDI | CTRL_POLLED);
+   write_wd33c93(regs, WD_SYNCHRONOUS_TRANSFER,
                  calc_sync_xfer(hostdata->default_sx_per/4,DEFAULT_SX_OFF));
-   write_wd33c93(regp, WD_COMMAND, WD_CMD_RESET);
+   write_wd33c93(regs, WD_COMMAND, WD_CMD_RESET);
 #ifdef CONFIG_MVME147_SCSI
    udelay(25); /* The old wd33c93 on MVME147 needs this, at least */
 #endif
 
    while (!(READ_AUX_STAT() & ASR_INT))
       ;
-   sr = read_wd33c93(regp, WD_SCSI_STATUS);
+   sr = read_wd33c93(regs, WD_SCSI_STATUS);
 
-   hostdata->microcode = read_wd33c93(regp, WD_CDB_1);
+   hostdata->microcode = read_wd33c93(regs, WD_CDB_1);
    if (sr == 0x00)
       hostdata->chip = C_WD33C93;
    else if (sr == 0x01) {
-      write_wd33c93(regp, WD_QUEUE_TAG, 0xa5);  /* any random number */
-      sr = read_wd33c93(regp, WD_QUEUE_TAG);
+      write_wd33c93(regs, WD_QUEUE_TAG, 0xa5);  /* any random number */
+      sr = read_wd33c93(regs, WD_QUEUE_TAG);
       if (sr == 0xa5) {
          hostdata->chip = C_WD33C93B;
-         write_wd33c93(regp, WD_QUEUE_TAG, 0);
+         write_wd33c93(regs, WD_QUEUE_TAG, 0);
          }
       else
          hostdata->chip = C_WD33C93A;
@@ -1450,8 +1443,8 @@
    else
       hostdata->chip = C_UNKNOWN_CHIP;
 
-   write_wd33c93(regp, WD_TIMEOUT_PERIOD, TIMEOUT_PERIOD_VALUE);
-   write_wd33c93(regp, WD_CONTROL, CTRL_IDI | CTRL_EDI | CTRL_POLLED);
+   write_wd33c93(regs, WD_TIMEOUT_PERIOD, TIMEOUT_PERIOD_VALUE);
+   write_wd33c93(regs, WD_CONTROL, CTRL_IDI | CTRL_EDI | CTRL_POLLED);
 }
 
 
@@ -1495,14 +1488,14 @@
 {
 struct Scsi_Host *instance;
 struct WD33C93_hostdata *hostdata;
-wd33c93_regs *regp;
+wd33c93_regs regs;
 Scsi_Cmnd *tmp, *prev;
 
    disable_irq(cmd->host->irq);
 
    instance = cmd->host;
    hostdata = (struct WD33C93_hostdata *)instance->hostdata;
-   regp = hostdata->regp;
+   regs = hostdata->regs;
 
 /*
  * Case 1 : If the command hasn't been issued yet, we simply remove it
@@ -1554,8 +1547,8 @@
          }
 
       printk("sending wd33c93 ABORT command - ");
-      write_wd33c93(regp, WD_CONTROL, CTRL_IDI | CTRL_EDI | CTRL_POLLED);
-      write_wd33c93_cmd(regp, WD_CMD_ABORT);
+      write_wd33c93(regs, WD_CONTROL, CTRL_IDI | CTRL_EDI | CTRL_POLLED);
+      write_wd33c93_cmd(regs, WD_CMD_ABORT);
 
 /* Now we have to attempt to flush out the FIFO... */
 
@@ -1564,11 +1557,11 @@
       do {
          asr = READ_AUX_STAT();
          if (asr & ASR_DBR)
-            read_wd33c93(regp, WD_DATA);
+            read_wd33c93(regs, WD_DATA);
          } while (!(asr & ASR_INT) && timeout-- > 0);
-      sr = read_wd33c93(regp, WD_SCSI_STATUS);
+      sr = read_wd33c93(regs, WD_SCSI_STATUS);
       printk("asr=%02x, sr=%02x, %ld bytes un-transferred (timeout=%ld) - ",
-             asr, sr, read_wd33c93_count(regp), timeout);
+             asr, sr, read_wd33c93_count(regs), timeout);
 
    /*
     * Abort command processed.
@@ -1577,13 +1570,13 @@
     */
 
       printk("sending wd33c93 DISCONNECT command - ");
-      write_wd33c93_cmd(regp, WD_CMD_DISCONNECT);
+      write_wd33c93_cmd(regs, WD_CMD_DISCONNECT);
 
       timeout = 1000000;
       asr = READ_AUX_STAT();
       while ((asr & ASR_CIP) && timeout-- > 0)
          asr = READ_AUX_STAT();
-      sr = read_wd33c93(regp, WD_SCSI_STATUS);
+      sr = read_wd33c93(regs, WD_SCSI_STATUS);
       printk("asr=%02x, sr=%02x.",asr,sr);
 
       hostdata->busy[cmd->target] &= ~(1 << cmd->lun);
@@ -1733,8 +1726,8 @@
 
 
 
-void wd33c93_init (struct Scsi_Host *instance, wd33c93_regs *regs,
-         dma_setup_t setup, dma_stop_t stop, int clock_freq)
+void wd33c93_init(struct Scsi_Host *instance, const wd33c93_regs regs,
+		  dma_setup_t setup, dma_stop_t stop, int clock_freq)
 {
 struct WD33C93_hostdata *hostdata;
 int i;
@@ -1747,7 +1740,7 @@
 
    hostdata = (struct WD33C93_hostdata *)instance->hostdata;
 
-   hostdata->regp = regs;
+   hostdata->regs = regs;
    hostdata->clock_freq = clock_freq;
    hostdata->dma_setup = setup;
    hostdata->dma_stop = stop;
@@ -2036,8 +2029,8 @@
 #ifdef MODULE
 int init_module(void) { return 0; }
 void cleanup_module(void) {}
+#endif
 void wd33c93_release(void)
 {
-MOD_DEC_USE_COUNT;
+   MOD_DEC_USE_COUNT;
 }
-#endif

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)