This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / drivers / scsi / advansys.c
index d796cac..8eb05dd 100644 (file)
@@ -1,4 +1,4 @@
-#define ASC_VERSION "3.3K"    /* AdvanSys Driver Version */
+#define ASC_VERSION "3.3GJ"    /* AdvanSys Driver Version */
 
 /*
  * advansys.c - Linux Host Driver for AdvanSys SCSI Adapters
          1. change select_queue_depths to slave_configure
         2. make cmd_per_lun be sane again
 
-     3.3K [2004/06/24]:
-         1. continuing cleanup for lk 2.6 series
-         2. Fix problem in lk 2.6.7-bk2 that broke PCI wide cards
-         3. Fix problem that oopsed ISA cards
-
   I. Known Problems/Fix List (XXX)
 
      1. Need to add memory mapping workaround. Test the memory mapping.
 #include <asm/system.h>
 #include <asm/dma.h>
 
-/* FIXME: (by jejb@steeleye.com) This warning is present for two
- * reasons:
- *
- * 1) This driver badly needs converting to the correct driver model
- *    probing API
- *
- * 2) Although all of the necessary command mapping places have the
- * appropriate dma_map.. APIs, the driver still processes its internal
- * queue using bus_to_virt() and virt_to_bus() which are illegal under
- * the API.  The entire queue processing structure will need to be
- * altered to fix this.
- */
-#warning this driver is still not properly converted to the DMA API
-
-#include <scsi/scsi_cmnd.h>
-#include <scsi/scsi_device.h>
-#include <scsi/scsi.h>
+#include "scsi.h"
 #include <scsi/scsi_host.h>
 #include "advansys.h"
 #ifdef CONFIG_PCI
@@ -3516,7 +3495,7 @@ typedef struct {
 #define ASC_BUSY        0
 #define ASC_ERROR       (-1)
 
-/* struct scsi_cmnd function return codes */
+/* Scsi_Cmnd function return codes */
 #define STATUS_BYTE(byte)   (byte)
 #define MSG_BYTE(byte)      ((byte) << 8)
 #define HOST_BYTE(byte)     ((byte) << 16)
@@ -3533,7 +3512,7 @@ typedef struct {
  *  REQPTIME(reqp) - reqp's time stamp value
  *  REQTIMESTAMP() - system time stamp value
  */
-typedef struct scsi_cmnd     REQ, *REQP;
+typedef Scsi_Cmnd            REQ, *REQP;
 #define REQPNEXT(reqp)       ((REQP) ((reqp)->host_scribble))
 #define REQPNEXTP(reqp)      ((REQP *) &((reqp)->host_scribble))
 #define REQPTID(reqp)        ((reqp)->device->id)
@@ -3848,7 +3827,7 @@ typedef struct adv_sgblk {
 typedef struct adv_req {
     ADV_SCSI_REQ_Q      scsi_req_q;   /* Adv Library request structure. */
     uchar               align[32];    /* Request structure padding. */
-    struct scsi_cmnd   *cmndp;       /* Mid-Level SCSI command pointer. */
+    Scsi_Cmnd           *cmndp;       /* Mid-Level SCSI command pointer. */
     adv_sgblk_t         *sgblkp;      /* Adv Library scatter-gather pointer. */
     struct adv_req      *next_reqp;   /* Next Request Structure. */
 } adv_req_t;
@@ -3876,7 +3855,7 @@ typedef struct asc_board {
     asc_queue_t          waiting;               /* Waiting command queue */
     asc_queue_t          done;                  /* Done command queue */
     ADV_SCSI_BIT_ID_TYPE init_tidmask;          /* Target init./valid mask */
-    struct scsi_device *device[ADV_MAX_TID+1]; /* Mid-Level Scsi Device */
+    Scsi_Device          *device[ADV_MAX_TID+1]; /* Mid-Level Scsi Device */
     ushort               reqcnt[ADV_MAX_TID+1]; /* Starvation request count */
     ADV_SCSI_BIT_ID_TYPE queue_full;            /* Queue full mask */
     ushort               queue_full_cnt[ADV_MAX_TID+1]; /* Queue full count */
@@ -4025,12 +4004,12 @@ STATIC PortAddr     _asc_def_iop_base[];
  */
 
 STATIC irqreturn_t advansys_interrupt(int, void *, struct pt_regs *);
-STATIC int       advansys_slave_configure(struct scsi_device *);
-STATIC void       asc_scsi_done_list(struct scsi_cmnd *);
-STATIC int        asc_execute_scsi_cmnd(struct scsi_cmnd *);
-STATIC int        asc_build_req(asc_board_t *, struct scsi_cmnd *);
-STATIC int        adv_build_req(asc_board_t *, struct scsi_cmnd *, ADV_SCSI_REQ_Q **);
-STATIC int        adv_get_sglist(asc_board_t *, adv_req_t *, struct scsi_cmnd *, int);
+STATIC int       advansys_slave_configure(Scsi_Device *);
+STATIC void       asc_scsi_done_list(Scsi_Cmnd *);
+STATIC int        asc_execute_scsi_cmnd(Scsi_Cmnd *);
+STATIC int        asc_build_req(asc_board_t *, Scsi_Cmnd *);
+STATIC int        adv_build_req(asc_board_t *, Scsi_Cmnd *, ADV_SCSI_REQ_Q **);
+STATIC int        adv_get_sglist(asc_board_t *, adv_req_t *, Scsi_Cmnd *, int);
 STATIC void       asc_isr_callback(ASC_DVC_VAR *, ASC_QDONE_INFO *);
 STATIC void       adv_isr_callback(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *);
 STATIC void       adv_async_callback(ADV_DVC_VAR *, uchar);
@@ -4067,7 +4046,7 @@ STATIC int          asc_prt_target_stats(struct Scsi_Host *, int, char *, int);
 /* Debug function prototypes. */
 #ifdef ADVANSYS_DEBUG
 STATIC void         asc_prt_scsi_host(struct Scsi_Host *);
-STATIC void         asc_prt_scsi_cmnd(struct scsi_cmnd *);
+STATIC void         asc_prt_scsi_cmnd(Scsi_Cmnd *);
 STATIC void         asc_prt_asc_dvc_cfg(ASC_DVC_CFG *);
 STATIC void         asc_prt_asc_dvc_var(ASC_DVC_VAR *);
 STATIC void         asc_prt_asc_scsi_q(ASC_SCSI_Q *);
@@ -4322,7 +4301,7 @@ advansys_proc_info(struct Scsi_Host *shost, char *buffer, char **start,
  * and scsi_free().
  */
 int __init
-advansys_detect(struct scsi_host_template *tpnt)
+advansys_detect(Scsi_Host_Template *tpnt)
 {
     static int          detect_called = ASC_FALSE;
     int                 iop;
@@ -5598,12 +5577,12 @@ advansys_info(struct Scsi_Host *shp)
  * in the 'scp' result field.
  */
 int
-advansys_queuecommand(struct scsi_cmnd *scp, void (*done)(struct scsi_cmnd *))
+advansys_queuecommand(Scsi_Cmnd *scp, void (*done)(Scsi_Cmnd *))
 {
     struct Scsi_Host    *shp;
     asc_board_t         *boardp;
     ulong               flags;
-    struct scsi_cmnd           *done_scp;
+    Scsi_Cmnd           *done_scp;
 
     shp = scp->device->host;
     boardp = ASC_BOARDP(shp);
@@ -5686,15 +5665,15 @@ advansys_queuecommand(struct scsi_cmnd *scp, void (*done)(struct scsi_cmnd *))
  * required. Returns SUCCESS or FAILED.
  */
 int
-advansys_reset(struct scsi_cmnd *scp)
+advansys_reset(Scsi_Cmnd *scp)
 {
     struct Scsi_Host     *shp;
     asc_board_t          *boardp;
     ASC_DVC_VAR          *asc_dvc_varp;
     ADV_DVC_VAR          *adv_dvc_varp;
     ulong                flags;
-    struct scsi_cmnd            *done_scp = NULL, *last_scp = NULL;
-    struct scsi_cmnd            *tscp, *new_last_scp;
+    Scsi_Cmnd            *done_scp = NULL, *last_scp = NULL;
+    Scsi_Cmnd            *tscp, *new_last_scp;
     int                  status;
     int                  ret = SUCCESS;
 
@@ -5983,7 +5962,7 @@ advansys_setup(char *str, int *ints)
  * --- Loadable Driver Support
  */
 
-static struct scsi_host_template driver_template = {
+static Scsi_Host_Template driver_template = {
     .proc_name                  = "advansys",
 #ifdef CONFIG_PROC_FS
     .proc_info                  = advansys_proc_info,
@@ -6033,8 +6012,8 @@ advansys_interrupt(int irq, void *dev_id, struct pt_regs *regs)
     ulong           flags;
     int             i;
     asc_board_t     *boardp;
-    struct scsi_cmnd       *done_scp = NULL, *last_scp = NULL;
-    struct scsi_cmnd       *new_last_scp;
+    Scsi_Cmnd       *done_scp = NULL, *last_scp = NULL;
+    Scsi_Cmnd       *new_last_scp;
     struct Scsi_Host *shp;
 
     ASC_DBG(1, "advansys_interrupt: begin\n");
@@ -6125,7 +6104,7 @@ advansys_interrupt(int irq, void *dev_id, struct pt_regs *regs)
  * specified host adapter.
  */
 STATIC int
-advansys_slave_configure(struct scsi_device *device)
+advansys_slave_configure(Scsi_Device *device)
 {
     asc_board_t        *boardp;
 
@@ -6160,9 +6139,9 @@ advansys_slave_configure(struct scsi_device *device)
  * Interrupts can be enabled on entry.
  */
 STATIC void
-asc_scsi_done_list(struct scsi_cmnd *scp)
+asc_scsi_done_list(Scsi_Cmnd *scp)
 {
-    struct scsi_cmnd    *tscp;
+    Scsi_Cmnd    *tscp;
 
     ASC_DBG(2, "asc_scsi_done_list: begin\n");
     while (scp != NULL) {
@@ -6232,7 +6211,7 @@ asc_scsi_done_list(struct scsi_cmnd *scp)
  *  host driver fields:
  *    SCp - Scsi_Pointer used for command processing status
  *    scsi_done - used to save caller's done function
- *    host_scribble - used for pointer to another struct scsi_cmnd
+ *    host_scribble - used for pointer to another Scsi_Cmnd
  *
  * If this function returns ASC_NOERROR the request has been enqueued
  * on the board's 'active' queue and will be completed from the
@@ -6245,13 +6224,13 @@ asc_scsi_done_list(struct scsi_cmnd *scp)
  * caller on the target's waiting queue and re-tried later.
  */
 STATIC int
-asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
+asc_execute_scsi_cmnd(Scsi_Cmnd *scp)
 {
     asc_board_t        *boardp;
     ASC_DVC_VAR        *asc_dvc_varp;
     ADV_DVC_VAR        *adv_dvc_varp;
     ADV_SCSI_REQ_Q     *adv_scsiqp;
-    struct scsi_device *device;
+    Scsi_Device        *device;
     int                ret;
 
     ASC_DBG2(1, "asc_execute_scsi_cmnd: scp 0x%lx, done 0x%lx\n",
@@ -6418,7 +6397,7 @@ asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
  * queue and return ASC_ERROR.
  */
 STATIC int
-asc_build_req(asc_board_t *boardp, struct scsi_cmnd *scp)
+asc_build_req(asc_board_t *boardp, Scsi_Cmnd *scp)
 {
     struct device *dev = boardp->dvc_cfg.asc_dvc_cfg.dev;
 
@@ -6429,7 +6408,7 @@ asc_build_req(asc_board_t *boardp, struct scsi_cmnd *scp)
     memset(&asc_scsi_q, 0, sizeof(ASC_SCSI_Q));
 
     /*
-     * Point the ASC_SCSI_Q to the 'struct scsi_cmnd'.
+     * Point the ASC_SCSI_Q to the 'Scsi_Cmnd'.
      */
     asc_scsi_q.q2.srb_ptr = ASC_VADDR_TO_U32(scp);
 
@@ -6555,7 +6534,7 @@ asc_build_req(asc_board_t *boardp, struct scsi_cmnd *scp)
  * to little-endian order.
  */
 STATIC int
-adv_build_req(asc_board_t *boardp, struct scsi_cmnd *scp,
+adv_build_req(asc_board_t *boardp, Scsi_Cmnd *scp,
     ADV_SCSI_REQ_Q **adv_scsiqpp)
 {
     adv_req_t           *reqp;
@@ -6594,7 +6573,7 @@ adv_build_req(asc_board_t *boardp, struct scsi_cmnd *scp,
     scsiqp->srb_ptr = ASC_VADDR_TO_U32(reqp);
 
     /*
-     * Set the adv_req_t 'cmndp' to point to the struct scsi_cmnd structure.
+     * Set the adv_req_t 'cmndp' to point to the Scsi_Cmnd structure.
      */
     reqp->cmndp = scp;
 
@@ -6636,10 +6615,6 @@ adv_build_req(asc_board_t *boardp, struct scsi_cmnd *scp,
      * buffer command.
      */
 
-    scsiqp->data_cnt = cpu_to_le32(scp->request_bufflen);
-    scsiqp->vdata_addr = scp->request_buffer;
-    scsiqp->data_addr = cpu_to_le32(virt_to_bus(scp->request_buffer));
-
     if (scp->use_sg == 0) {
         /*
          * CDB request of single contiguous buffer.
@@ -6668,6 +6643,10 @@ adv_build_req(asc_board_t *boardp, struct scsi_cmnd *scp,
        struct scatterlist *slp;
        int use_sg;
 
+       scsiqp->data_cnt = 0;
+       scsiqp->vdata_addr = 0;
+       scsiqp->data_addr = 0;
+
        slp = (struct scatterlist *)scp->request_buffer;
        use_sg = dma_map_sg(dev, slp, scp->use_sg, scp->sc_data_direction);
 
@@ -6725,7 +6704,7 @@ adv_build_req(asc_board_t *boardp, struct scsi_cmnd *scp,
  *      ADV_ERROR(-1) - SG List creation failed
  */
 STATIC int
-adv_get_sglist(asc_board_t *boardp, adv_req_t *reqp, struct scsi_cmnd *scp, int use_sg)
+adv_get_sglist(asc_board_t *boardp, adv_req_t *reqp, Scsi_Cmnd *scp, int use_sg)
 {
     adv_sgblk_t         *sgblkp;
     ADV_SCSI_REQ_Q      *scsiqp;
@@ -6837,7 +6816,7 @@ STATIC void
 asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep)
 {
     asc_board_t         *boardp;
-    struct scsi_cmnd           *scp;
+    Scsi_Cmnd           *scp;
     struct Scsi_Host    *shp;
     int                 i;
 
@@ -6846,10 +6825,10 @@ asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep)
     ASC_DBG_PRT_ASC_QDONE_INFO(2, qdonep);
 
     /*
-     * Get the struct scsi_cmnd structure and Scsi_Host structure for the
+     * Get the Scsi_Cmnd structure and Scsi_Host structure for the
      * command that has been completed.
      */
-    scp = (struct scsi_cmnd *) ASC_U32_TO_VADDR(qdonep->d2.srb_ptr);
+    scp = (Scsi_Cmnd *) ASC_U32_TO_VADDR(qdonep->d2.srb_ptr);
     ASC_DBG1(1, "asc_isr_callback: scp 0x%lx\n", (ulong) scp);
 
     if (scp == NULL) {
@@ -6984,7 +6963,7 @@ asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep)
     }
 
     /*
-     * Because interrupts may be enabled by the 'struct scsi_cmnd' done
+     * Because interrupts may be enabled by the 'Scsi_Cmnd' done
      * function, add the command to the end of the board's done queue.
      * The done function for the command will be called from
      * advansys_interrupt().
@@ -7005,7 +6984,7 @@ adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
     asc_board_t         *boardp;
     adv_req_t           *reqp;
     adv_sgblk_t         *sgblkp;
-    struct scsi_cmnd           *scp;
+    Scsi_Cmnd           *scp;
     struct Scsi_Host    *shp;
     int                 i;
     ADV_DCNT            resid_cnt;
@@ -7028,7 +7007,7 @@ adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
     }
 
     /*
-     * Get the struct scsi_cmnd structure and Scsi_Host structure for the
+     * Get the Scsi_Cmnd structure and Scsi_Host structure for the
      * command that has been completed.
      *
      * Note: The adv_req_t request structure and adv_sgblk_t structure,
@@ -7163,7 +7142,7 @@ adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
     }
 
     /*
-     * Because interrupts may be enabled by the 'struct scsi_cmnd' done
+     * Because interrupts may be enabled by the 'Scsi_Cmnd' done
      * function, add the command to the end of the board's done queue.
      * The done function for the command will be called from
      * advansys_interrupt().
@@ -7487,7 +7466,7 @@ asc_rmqueue(asc_queue_t *ascq, REQP reqp)
 /*
  * Execute as many queued requests as possible for the specified queue.
  *
- * Calls asc_execute_scsi_cmnd() to execute a REQP/struct scsi_cmnd.
+ * Calls asc_execute_scsi_cmnd() to execute a REQP/Scsi_Cmnd.
  */
 STATIC void
 asc_execute_queue(asc_queue_t *ascq)
@@ -7507,7 +7486,7 @@ asc_execute_queue(asc_queue_t *ascq)
             if (scan_tidmask & ADV_TID_TO_TIDMASK(i)) {
                 if ((reqp = asc_dequeue(ascq, i)) == NULL) {
                     scan_tidmask &= ~ADV_TID_TO_TIDMASK(i);
-                } else if (asc_execute_scsi_cmnd((struct scsi_cmnd *) reqp)
+                } else if (asc_execute_scsi_cmnd((Scsi_Cmnd *) reqp)
                             == ASC_BUSY) {
                     scan_tidmask &= ~ADV_TID_TO_TIDMASK(i);
                     /*
@@ -9191,9 +9170,9 @@ asc_prt_scsi_host(struct Scsi_Host *s)
  * asc_prt_scsi_cmnd()
  */
 STATIC void
-asc_prt_scsi_cmnd(struct scsi_cmnd *s)
+asc_prt_scsi_cmnd(Scsi_Cmnd *s)
 {
-    printk("struct scsi_cmnd at addr 0x%lx\n", (ulong) s);
+    printk("Scsi_Cmnd at addr 0x%lx\n", (ulong) s);
 
     printk(
 " host 0x%lx, device 0x%lx, target %u, lun %u, channel %u,\n",
@@ -9219,7 +9198,9 @@ asc_prt_scsi_cmnd(struct scsi_cmnd *s)
 " timeout_per_command %d, timeout_total %d, timeout %d\n",
         s->timeout_per_command, s->timeout_total, s->timeout);
 
-    printk(" internal_timeout %u\n", s->internal_timeout);
+    printk(
+" internal_timeout %u, flags %u\n",
+        s->internal_timeout, s->flags);
 
     printk(
 " scsi_done 0x%lx, done 0x%lx, host_scribble 0x%lx, result 0x%x\n",
@@ -12030,10 +12011,7 @@ AscInitFromAscDvcVar(
     ushort              pci_device_id;
 
     iop_base = asc_dvc->iop_base;
-    if (asc_dvc->cfg->dev)
-        pci_device_id = to_pci_dev(asc_dvc->cfg->dev)->device;
-    else
-       pci_device_id = 0;
+    pci_device_id = to_pci_dev(asc_dvc->cfg->dev)->device;
     warn_code = 0;
     cfg_msw = AscGetChipCfgMsw(iop_base);
     if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {