This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / drivers / scsi / i91uscsi.c
similarity index 82%
rename from drivers/scsi/initio.c
rename to drivers/scsi/i91uscsi.c
index a7b74d8..53f319d 100644 (file)
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *************************************************************************
- *
- * DESCRIPTION:
- *
- * This is the Linux low-level SCSI driver for Initio INI-9X00U/UW SCSI host
- * adapters
- *
- * 08/06/97 hc - v1.01h
- *             - Support inic-940 and inic-935
- * 09/26/97 hc - v1.01i
- *             - Make correction from J.W. Schultz suggestion
- * 10/13/97 hc - Support reset function
- * 10/21/97 hc - v1.01j
- *             - Support 32 LUN (SCSI 3)
- * 01/14/98 hc - v1.01k
- *             - Fix memory allocation problem
- * 03/04/98 hc - v1.01l
- *             - Fix tape rewind which will hang the system problem
- *             - Set can_queue to tul_num_scb
- * 06/25/98 hc - v1.01m
- *             - Get it work for kernel version >= 2.1.75
- *             - Dynamic assign SCSI bus reset holding time in init_tulip()
- * 07/02/98 hc - v1.01n
- *             - Support 0002134A
- * 08/07/98 hc  - v1.01o
- *             - Change the tul_abort_srb routine to use scsi_done. <01>
- * 09/07/98 hl  - v1.02
- *              - Change the INI9100U define and proc_dir_entry to
- *                reflect the newer Kernel 2.1.118, but the v1.o1o
- *                should work with Kernel 2.1.118.
- * 09/20/98 wh  - v1.02a
- *              - Support Abort command.
- *              - Handle reset routine.
- * 09/21/98 hl  - v1.03
- *              - remove comments.
- * 12/09/98 bv - v1.03a
- *             - Removed unused code
- * 12/13/98 bv - v1.03b
- *             - Remove cli() locking for kernels >= 2.1.95. This uses
- *               spinlocks to serialize access to the pSRB_head and
- *               pSRB_tail members of the HCS structure.
- * 09/01/99 bv - v1.03d
- *             - Fixed a deadlock problem in SMP.
- * 21/01/99 bv - v1.03e
- *             - Add support for the Domex 3192U PCI SCSI
- *               This is a slightly modified patch by
- *               Brian Macy <bmacy@sunshinecomputing.com>
- * 22/02/99 bv - v1.03f
- *             - Didn't detect the INIC-950 in 2.0.x correctly.
- *               Now fixed.
- * 05/07/99 bv - v1.03g
- *             - Changed the assumption that HZ = 100
- * 10/17/03 mc - v1.04
- *             - added new DMA API support
- * 06/01/04 jmd        - v1.04a
- *             - Re-add reset_bus support
- **************************************************************************/
-
-#include <linux/module.h>
-#include <linux/errno.h>
-#include <linux/delay.h>
-#include <linux/pci.h>
-#include <linux/init.h>
-#include <linux/blkdev.h>
-#include <linux/spinlock.h>
-#include <linux/stat.h>
-#include <linux/config.h>
-#include <linux/kernel.h>
-#include <linux/proc_fs.h>
-#include <linux/string.h>
-#include <linux/interrupt.h>
-#include <linux/ioport.h>
-#include <linux/sched.h>
-#include <linux/slab.h>
-#include <linux/jiffies.h>
-#include <asm/io.h>
-
-#include <scsi/scsi.h>
-#include <scsi/scsi_cmnd.h>
-#include <scsi/scsi_device.h>
-#include <scsi/scsi_host.h>
-#include <scsi/scsi_tcq.h>
-
-#include "initio.h"
-
-#define SENSE_SIZE             14
-
-#define i91u_MAXQUEUE          2
-#define i91u_REVID "Initio INI-9X00U/UW SCSI device driver; Revision: 1.04a"
-
-#define INI_VENDOR_ID   0x1101 /* Initio's PCI vendor ID       */
-#define DMX_VENDOR_ID  0x134a  /* Domex's PCI vendor ID        */
-#define I950_DEVICE_ID 0x9500  /* Initio's inic-950 product ID   */
-#define I940_DEVICE_ID 0x9400  /* Initio's inic-940 product ID   */
-#define I935_DEVICE_ID 0x9401  /* Initio's inic-935 product ID   */
-#define I920_DEVICE_ID 0x0002  /* Initio's other product ID      */
-
-#ifdef DEBUG_i91u
-static unsigned int i91u_debug = DEBUG_DEFAULT;
-#endif
-
-#define TULSZ(sz)     (sizeof(sz) / sizeof(sz[0]))
-#define TUL_RDWORD(x,y)         (short)(inl((int)((ULONG)((ULONG)x+(UCHAR)y)) ))
-
-typedef struct PCI_ID_Struc {
-       unsigned short vendor_id;
-       unsigned short device_id;
-} PCI_ID;
-
-static int tul_num_ch = 4;     /* Maximum 4 adapters           */
-static int tul_num_scb;
-static int tul_tag_enable = 1;
-static SCB *tul_scb;
-
-#ifdef DEBUG_i91u
-static int setup_debug = 0;
-#endif
-
-static void i91uSCBPost(BYTE * pHcb, BYTE * pScb);
-
-static const PCI_ID i91u_pci_devices[] = {
-       { INI_VENDOR_ID, I950_DEVICE_ID },
-       { INI_VENDOR_ID, I940_DEVICE_ID },
-       { INI_VENDOR_ID, I935_DEVICE_ID },
-       { INI_VENDOR_ID, I920_DEVICE_ID },
-       { DMX_VENDOR_ID, I920_DEVICE_ID },
-};
+ ************************************************************************
+    Module: i91uscsi.c
+    Description: PCI I/F for INI-910 SCSI Bus Master Controller
+    Revision History:
+       11/09/94 Tim Chen, Initiali Version 0.90A
+       01/17/95 TC, release ver 1.01
+       02/09/95 TC  modify ReadPCIConfig, try both mechanisms;
+       02/15/95 TC  add support for INI-9100W
+       06/04/96 HC, Change to fit LINUX from jaspci.c
+       11/18/96 HC, Port for tulip
+       07/08/98 hc, Support 0002134A
+        07/23/98 wh, Change the abort_srb routine.
+       09/16/98 hl, Support ALPHA, Rewrite the returnNumberAdapters    <01>
+       12/09/98 bv, Removed unused code, changed tul_se2_wait to
+                    use udelay(30) and tul_do_pause to enable 
+                    interrupts for >= 2.1.95
+       12/13/98 bv, Use spinlocks instead of cli() for serialized
+                    access to HCS_Semaph, HCS_FirstAvail and HCS_LastAvail
+                    members of the HCS structure.
+       01/09/98 bv, Fix a deadlock on SMP system.
+**********************************************************************/
 
 #define DEBUG_INTERRUPT 0
 #define DEBUG_QUEUE     0
 #define DEBUG_STATE     0
 #define INT_DISC       0
 
+#include <linux/jiffies.h>
+#include <linux/delay.h>
+#include <linux/blkdev.h>
+#include <asm/io.h>
+
+#include "i91uscsi.h"
+
 /*--- external functions --*/
 static void tul_se2_wait(void);
 
@@ -304,6 +205,9 @@ static UCHAR tul_rate_tbl[8] =      /* fast 20      */
        62                      /* 250ns, 4M    */
 };
 
+extern int tul_num_ch;
+
+
 static void tul_do_pause(unsigned amount)
 {                              /* Pause for amount jiffies */
        unsigned long the_time = jiffies + amount;
@@ -316,7 +220,7 @@ static void tul_do_pause(unsigned amount)
 /*******************************************************************
        Use memeory refresh time        ~ 15us * 2
 ********************************************************************/
-void tul_se2_wait(void)
+void tul_se2_wait()
 {
 #if 1
        udelay(30);
@@ -595,7 +499,7 @@ int Addi91u_into_Adapter_table(WORD wBIOS, WORD wBASE, BYTE bInterrupt,
                if (i91u_adpt[i].ADPT_BIOS == wBIOS) {
                        if (i91u_adpt[i].ADPT_BASE == wBASE) {
                                if (i91u_adpt[i].ADPT_Bus != 0xFF)
-                                       return 1;
+                                       return (FAILURE);
                        } else if (i91u_adpt[i].ADPT_BASE < wBASE)
                                        continue;
                }
@@ -611,9 +515,9 @@ int Addi91u_into_Adapter_table(WORD wBIOS, WORD wBASE, BYTE bInterrupt,
                i91u_adpt[i].ADPT_BIOS = wBIOS;
                i91u_adpt[i].ADPT_Bus = bBus;
                i91u_adpt[i].ADPT_Device = bDevice;
-               return 0;
+               return (SUCCESSFUL);
        }
-       return 1;
+       return (FAILURE);
 }
 
 void init_i91uAdapter_table(void)
@@ -679,7 +583,7 @@ int init_tulip(HCS * pCurHcb, SCB * scbp, int tul_num_scb, BYTE * pbBiosAdr, int
 
        pCurHcb->HCS_NumScbs = tul_num_scb;
        pCurHcb->HCS_Semaph = 1;
-       spin_lock_init(&pCurHcb->HCS_SemaphLock);
+       pCurHcb->HCS_SemaphLock = SPIN_LOCK_UNLOCKED;
        pCurHcb->HCS_JSStatus0 = 0;
        pCurHcb->HCS_Scb = scbp;
        pCurHcb->HCS_NxtPend = scbp;
@@ -694,7 +598,7 @@ int init_tulip(HCS * pCurHcb, SCB * scbp, int tul_num_scb, BYTE * pbBiosAdr, int
        pCurHcb->HCS_ScbEnd = pTmpScb;
        pCurHcb->HCS_FirstAvail = scbp;
        pCurHcb->HCS_LastAvail = pPrevScb;
-       spin_lock_init(&pCurHcb->HCS_AvailLock);
+       pCurHcb->HCS_AvailLock = SPIN_LOCK_UNLOCKED;
        pCurHcb->HCS_FirstPend = NULL;
        pCurHcb->HCS_LastPend = NULL;
        pCurHcb->HCS_FirstBusy = NULL;
@@ -815,7 +719,7 @@ void tul_release_scb(HCS * hcsp, SCB * scbp)
        printk("Release SCB %lx; ", (ULONG) scbp);
 #endif
        spin_lock_irqsave(&(hcsp->HCS_AvailLock), flags);
-       scbp->SCB_Srb = NULL;
+       scbp->SCB_Srb = 0;
        scbp->SCB_Status = 0;
        scbp->SCB_NxtScb = NULL;
        if (hcsp->HCS_LastAvail != NULL) {
@@ -1073,7 +977,7 @@ SCB *tul_find_done_scb(HCS * pCurHcb)
 }
 
 /***************************************************************************/
-int tul_abort_srb(HCS * pCurHcb, struct scsi_cmnd *srbp)
+int tul_abort_srb(HCS * pCurHcb, ULONG srbp)
 {
        ULONG flags;
        SCB *pTmpScb, *pPrevScb;
@@ -1100,7 +1004,7 @@ int tul_abort_srb(HCS * pCurHcb, struct scsi_cmnd *srbp)
        pPrevScb = pTmpScb = pCurHcb->HCS_FirstPend;    /* Check Pend queue */
        while (pTmpScb != NULL) {
                /* 07/27/98 */
-               if (pTmpScb->SCB_Srb == srbp) {
+               if (pTmpScb->SCB_Srb == (unsigned char *) srbp) {
                        if (pTmpScb == pCurHcb->HCS_ActScb) {
                                spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
                                return SCSI_ABORT_BUSY;
@@ -1126,7 +1030,7 @@ int tul_abort_srb(HCS * pCurHcb, struct scsi_cmnd *srbp)
        pPrevScb = pTmpScb = pCurHcb->HCS_FirstBusy;    /* Check Busy queue */
        while (pTmpScb != NULL) {
 
-               if (pTmpScb->SCB_Srb == srbp) {
+               if (pTmpScb->SCB_Srb == (unsigned char *) srbp) {
 
                        if (pTmpScb == pCurHcb->HCS_ActScb) {
                                spin_unlock_irqrestore(&(pCurHcb->HCS_SemaphLock), flags);
@@ -1183,8 +1087,7 @@ int tul_bad_seq(HCS * pCurHcb)
 }
 
 /************************************************************************/
-int tul_device_reset(HCS * pCurHcb, struct scsi_cmnd *pSrb,
-               unsigned int target, unsigned int ResetFlags)
+int tul_device_reset(HCS * pCurHcb, ULONG pSrb, unsigned int target, unsigned int ResetFlags)
 {
        ULONG flags;
        SCB *pScb;
@@ -1211,7 +1114,7 @@ int tul_device_reset(HCS * pCurHcb, struct scsi_cmnd *pSrb,
                }
                pScb = pCurHcb->HCS_FirstBusy;  /* Check Busy queue */
                while (pScb != NULL) {
-                       if (pScb->SCB_Srb == pSrb)
+                       if (pScb->SCB_Srb == (unsigned char *) pSrb)
                                break;
                        pScb = pScb->SCB_NxtScb;
                }
@@ -1231,9 +1134,9 @@ int tul_device_reset(HCS * pCurHcb, struct scsi_cmnd *pSrb,
        pScb->SCB_Target = target;
        pScb->SCB_Mode = 0;
 
-       pScb->SCB_Srb = NULL;
+       pScb->SCB_Srb = 0;
        if (ResetFlags & SCSI_RESET_SYNCHRONOUS) {
-               pScb->SCB_Srb = pSrb;
+               pScb->SCB_Srb = (unsigned char *) pSrb;
        }
        tul_push_pend_scb(pCurHcb, pScb);       /* push this SCB to Pending queue */
 
@@ -1348,7 +1251,7 @@ int tulip_main(HCS * pCurHcb)
                tulip_scsi(pCurHcb);    /* Call tulip_scsi              */
 
                while ((pCurScb = tul_find_done_scb(pCurHcb)) != NULL) {        /* find done entry */
-                       if (pCurScb->SCB_TaStat == INI_QUEUE_FULL) {
+                       if (pCurScb->SCB_TaStat == QUEUE_FULL) {
                                pCurHcb->HCS_MaxTags[pCurScb->SCB_Target] =
                                    pCurHcb->HCS_ActTags[pCurScb->SCB_Target] - 1;
                                pCurScb->SCB_TaStat = 0;
@@ -1506,7 +1409,11 @@ void tulip_scsi(HCS * pCurHcb)
                        }
                }
        } else if (pCurScb->SCB_Opcode == AbortCmd) {
-               if (tul_abort_srb(pCurHcb, pCurScb->SCB_Srb) != 0) {
+               ULONG srbp;
+
+               srbp = (ULONG) pCurScb->SCB_Srb;
+/* 08/03/98 */
+               if (tul_abort_srb(pCurHcb, srbp) != 0) {
 
 
                        tul_unlink_pend_scb(pCurHcb, pCurScb);
@@ -2535,8 +2442,8 @@ int tul_post_scsi_rst(HCS * pCurHcb)
        TCS *pCurTcb;
        int i;
 
-       pCurHcb->HCS_ActScb = NULL;
-       pCurHcb->HCS_ActTcs = NULL;
+       pCurHcb->HCS_ActScb = 0;
+       pCurHcb->HCS_ActTcs = 0;
        pCurHcb->HCS_Flags = 0;
 
        while ((pCurScb = tul_pop_busy_scb(pCurHcb)) != NULL) {
@@ -2762,423 +2669,4 @@ int tul_wait_done_disc(HCS * pCurHcb)
        return (tul_bad_seq(pCurHcb));
 }
 
-static irqreturn_t i91u_intr(int irqno, void *dev_id, struct pt_regs *regs)
-{
-       struct Scsi_Host *dev = dev_id;
-       unsigned long flags;
-       
-       spin_lock_irqsave(dev->host_lock, flags);
-       tul_isr((HCS *)dev->base);
-       spin_unlock_irqrestore(dev->host_lock, flags);
-       return IRQ_HANDLED;
-}
-
-static int tul_NewReturnNumberOfAdapters(void)
-{
-       struct pci_dev *pDev = NULL;    /* Start from none              */
-       int iAdapters = 0;
-       long dRegValue;
-       WORD wBIOS;
-       int i = 0;
-
-       init_i91uAdapter_table();
-
-       for (i = 0; i < TULSZ(i91u_pci_devices); i++)
-       {
-               while ((pDev = pci_find_device(i91u_pci_devices[i].vendor_id, i91u_pci_devices[i].device_id, pDev)) != NULL) {
-                       if (pci_enable_device(pDev))
-                               continue;
-                       pci_read_config_dword(pDev, 0x44, (u32 *) & dRegValue);
-                       wBIOS = (UWORD) (dRegValue & 0xFF);
-                       if (((dRegValue & 0xFF00) >> 8) == 0xFF)
-                               dRegValue = 0;
-                       wBIOS = (wBIOS << 8) + ((UWORD) ((dRegValue & 0xFF00) >> 8));
-                       if (pci_set_dma_mask(pDev, 0xffffffff)) {
-                               printk(KERN_WARNING 
-                                      "i91u: Could not set 32 bit DMA mask\n");
-                               continue;
-                       }
-
-                       if (Addi91u_into_Adapter_table(wBIOS,
-                                                       (pDev->resource[0].start),
-                                                       pDev->irq,
-                                                       pDev->bus->number,
-                                                       (pDev->devfn >> 3)
-                               ) == 0)
-                               iAdapters++;
-               }
-       }
-
-       return (iAdapters);
-}
-
-static int i91u_detect(struct scsi_host_template * tpnt)
-{
-       HCS *pHCB;
-       struct Scsi_Host *hreg;
-       unsigned long i;        /* 01/14/98                     */
-       int ok = 0, iAdapters;
-       ULONG dBiosAdr;
-       BYTE *pbBiosAdr;
-
-       /* Get total number of adapters in the motherboard */
-       iAdapters = tul_NewReturnNumberOfAdapters();
-       if (iAdapters == 0)     /* If no tulip founded, return */
-               return (0);
-
-       tul_num_ch = (iAdapters > tul_num_ch) ? tul_num_ch : iAdapters;
-       /* Update actually channel number */
-       if (tul_tag_enable) {   /* 1.01i                  */
-               tul_num_scb = MAX_TARGETS * i91u_MAXQUEUE;
-       } else {
-               tul_num_scb = MAX_TARGETS + 3;  /* 1-tape, 1-CD_ROM, 1- extra */
-       }                       /* Update actually SCBs per adapter */
-
-       /* Get total memory needed for HCS */
-       i = tul_num_ch * sizeof(HCS);
-       memset((unsigned char *) &tul_hcs[0], 0, i);    /* Initialize tul_hcs 0 */
-       /* Get total memory needed for SCB */
-
-       for (; tul_num_scb >= MAX_TARGETS + 3; tul_num_scb--) {
-               i = tul_num_ch * tul_num_scb * sizeof(SCB);
-               if ((tul_scb = (SCB *) kmalloc(i, GFP_ATOMIC | GFP_DMA)) != NULL)
-                       break;
-       }
-       if (tul_scb == NULL) {
-               printk("i91u: SCB memory allocation error\n");
-               return (0);
-       }
-       memset((unsigned char *) tul_scb, 0, i);
-
-       for (i = 0, pHCB = &tul_hcs[0];         /* Get pointer for control block */
-            i < tul_num_ch;
-            i++, pHCB++) {
-               get_tulipPCIConfig(pHCB, i);
-
-               dBiosAdr = pHCB->HCS_BIOS;
-               dBiosAdr = (dBiosAdr << 4);
-
-               pbBiosAdr = phys_to_virt(dBiosAdr);
-
-               init_tulip(pHCB, tul_scb + (i * tul_num_scb), tul_num_scb, pbBiosAdr, 10);
-               request_region(pHCB->HCS_Base, 256, "i91u"); /* Register */ 
-
-               pHCB->HCS_Index = i;    /* 7/29/98 */
-               hreg = scsi_register(tpnt, sizeof(HCS));
-               if(hreg == NULL) {
-                       release_region(pHCB->HCS_Base, 256);
-                       return 0;
-               }
-               hreg->io_port = pHCB->HCS_Base;
-               hreg->n_io_port = 0xff;
-               hreg->can_queue = tul_num_scb;  /* 03/05/98                      */
-               hreg->unique_id = pHCB->HCS_Base;
-               hreg->max_id = pHCB->HCS_MaxTar;
-               hreg->max_lun = 32;     /* 10/21/97                     */
-               hreg->irq = pHCB->HCS_Intr;
-               hreg->this_id = pHCB->HCS_SCSI_ID;      /* Assign HCS index           */
-               hreg->base = (unsigned long)pHCB;
-               hreg->sg_tablesize = TOTAL_SG_ENTRY;    /* Maximun support is 32 */
-
-               /* Initial tulip chip           */
-               ok = request_irq(pHCB->HCS_Intr, i91u_intr, SA_INTERRUPT | SA_SHIRQ, "i91u", hreg);
-               if (ok < 0) {
-                       printk(KERN_WARNING "i91u: unable to request IRQ %d\n\n", pHCB->HCS_Intr);
-                       return 0;
-               }
-       }
-
-       tpnt->this_id = -1;
-       tpnt->can_queue = 1;
-
-       return 1;
-}
-
-static void i91uBuildSCB(HCS * pHCB, SCB * pSCB, struct scsi_cmnd * SCpnt)
-{                              /* Create corresponding SCB     */
-       struct scatterlist *pSrbSG;
-       SG *pSG;                /* Pointer to SG list           */
-       int i;
-       long TotalLen;
-       dma_addr_t dma_addr;
-
-       pSCB->SCB_Post = i91uSCBPost;   /* i91u's callback routine      */
-       pSCB->SCB_Srb = SCpnt;
-       pSCB->SCB_Opcode = ExecSCSI;
-       pSCB->SCB_Flags = SCF_POST;     /* After SCSI done, call post routine */
-       pSCB->SCB_Target = SCpnt->device->id;
-       pSCB->SCB_Lun = SCpnt->device->lun;
-       pSCB->SCB_Ident = SCpnt->device->lun | DISC_ALLOW;
-
-       pSCB->SCB_Flags |= SCF_SENSE;   /* Turn on auto request sense   */
-       dma_addr = dma_map_single(&pHCB->pci_dev->dev, SCpnt->sense_buffer,
-                                 SENSE_SIZE, DMA_FROM_DEVICE);
-       pSCB->SCB_SensePtr = cpu_to_le32((u32)dma_addr);
-       pSCB->SCB_SenseLen = cpu_to_le32(SENSE_SIZE);
-       SCpnt->SCp.ptr = (char *)(unsigned long)dma_addr;
-
-       pSCB->SCB_CDBLen = SCpnt->cmd_len;
-       pSCB->SCB_HaStat = 0;
-       pSCB->SCB_TaStat = 0;
-       memcpy(&pSCB->SCB_CDB[0], &SCpnt->cmnd, SCpnt->cmd_len);
-
-       if (SCpnt->device->tagged_supported) {  /* Tag Support                  */
-               pSCB->SCB_TagMsg = SIMPLE_QUEUE_TAG;    /* Do simple tag only   */
-       } else {
-               pSCB->SCB_TagMsg = 0;   /* No tag support               */
-       }
-       /* todo handle map_sg error */
-       if (SCpnt->use_sg) {
-               dma_addr = dma_map_single(&pHCB->pci_dev->dev, &pSCB->SCB_SGList[0],
-                                         sizeof(struct SG_Struc) * TOTAL_SG_ENTRY,
-                                         DMA_BIDIRECTIONAL);
-               pSCB->SCB_BufPtr = cpu_to_le32((u32)dma_addr);
-               SCpnt->SCp.dma_handle = dma_addr;
-
-               pSrbSG = (struct scatterlist *) SCpnt->request_buffer;
-               pSCB->SCB_SGLen = dma_map_sg(&pHCB->pci_dev->dev, pSrbSG,
-                                            SCpnt->use_sg, SCpnt->sc_data_direction);
-
-               pSCB->SCB_Flags |= SCF_SG;      /* Turn on SG list flag       */
-               for (i = 0, TotalLen = 0, pSG = &pSCB->SCB_SGList[0];   /* 1.01g */
-                    i < pSCB->SCB_SGLen; i++, pSG++, pSrbSG++) {
-                       pSG->SG_Ptr = cpu_to_le32((u32)sg_dma_address(pSrbSG));
-                       TotalLen += pSG->SG_Len = cpu_to_le32((u32)sg_dma_len(pSrbSG));
-               }
-
-               pSCB->SCB_BufLen = (SCpnt->request_bufflen > TotalLen) ?
-                   TotalLen : SCpnt->request_bufflen;
-       } else if (SCpnt->request_bufflen) {            /* Non SG */
-               dma_addr = dma_map_single(&pHCB->pci_dev->dev, SCpnt->request_buffer,
-                                         SCpnt->request_bufflen,
-                                         SCpnt->sc_data_direction);
-               SCpnt->SCp.dma_handle = dma_addr;
-               pSCB->SCB_BufPtr = cpu_to_le32((u32)dma_addr);
-               pSCB->SCB_BufLen = cpu_to_le32((u32)SCpnt->request_bufflen);
-               pSCB->SCB_SGLen = 0;
-       } else {
-               pSCB->SCB_BufLen = 0;
-               pSCB->SCB_SGLen = 0;
-       }
-}
-
-static int i91u_queuecommand(struct scsi_cmnd *cmd,
-               void (*done)(struct scsi_cmnd *))
-{
-       HCS *pHCB = (HCS *) cmd->device->host->base;
-       register SCB *pSCB;
-
-       cmd->scsi_done = done;
-
-       pSCB = tul_alloc_scb(pHCB);
-       if (!pSCB)
-               return SCSI_MLQUEUE_HOST_BUSY;
-
-       i91uBuildSCB(pHCB, pSCB, cmd);
-       tul_exec_scb(pHCB, pSCB);
-       return 0;
-}
-
-#if 0 /* no new EH yet */
-/*
- *  Abort a queued command
- *  (commands that are on the bus can't be aborted easily)
- */
-static int i91u_abort(struct scsi_cmnd * SCpnt)
-{
-       HCS *pHCB;
-
-       pHCB = (HCS *) SCpnt->device->host->base;
-       return tul_abort_srb(pHCB, SCpnt);
-}
-
-/*
- *  Reset registers, reset a hanging bus and
- *  kill active and disconnected commands for target w/o soft reset
- */
-static int i91u_reset(struct scsi_cmnd * SCpnt, unsigned int reset_flags)
-{                              /* I need Host Control Block Information */
-       HCS *pHCB;
-
-       pHCB = (HCS *) SCpnt->device->host->base;
-
-       if (reset_flags & (SCSI_RESET_SUGGEST_BUS_RESET | SCSI_RESET_SUGGEST_HOST_RESET))
-               return tul_reset_scsi_bus(pHCB);
-       else
-               return tul_device_reset(pHCB, SCpnt, SCpnt->device->id, reset_flags);
-}
-#endif
-
-static int i91u_bus_reset(struct scsi_cmnd * SCpnt)
-{
-       HCS *pHCB;
-
-       pHCB = (HCS *) SCpnt->device->host->base;
-       tul_reset_scsi(pHCB, 0);
-       return SUCCESS;
-}
-
-/*
- * Return the "logical geometry"
- */
-static int i91u_biosparam(struct scsi_device *sdev, struct block_device *dev,
-               sector_t capacity, int *info_array)
-{
-       HCS *pHcb;              /* Point to Host adapter control block */
-       TCS *pTcb;
-
-       pHcb = (HCS *) sdev->host->base;
-       pTcb = &pHcb->HCS_Tcs[sdev->id];
-
-       if (pTcb->TCS_DrvHead) {
-               info_array[0] = pTcb->TCS_DrvHead;
-               info_array[1] = pTcb->TCS_DrvSector;
-               info_array[2] = (unsigned long)capacity / pTcb->TCS_DrvHead / pTcb->TCS_DrvSector;
-       } else {
-               if (pTcb->TCS_DrvFlags & TCF_DRV_255_63) {
-                       info_array[0] = 255;
-                       info_array[1] = 63;
-                       info_array[2] = (unsigned long)capacity / 255 / 63;
-               } else {
-                       info_array[0] = 64;
-                       info_array[1] = 32;
-                       info_array[2] = (unsigned long)capacity >> 11;
-               }
-       }
-
-#if defined(DEBUG_BIOSPARAM)
-       if (i91u_debug & debug_biosparam) {
-               printk("bios geometry: head=%d, sec=%d, cyl=%d\n",
-                      info_array[0], info_array[1], info_array[2]);
-               printk("WARNING: check, if the bios geometry is correct.\n");
-       }
-#endif
-
-       return 0;
-}
-
-static void i91u_unmap_cmnd(struct pci_dev *pci_dev, struct scsi_cmnd *cmnd)
-{
-       /* auto sense buffer */
-       if (cmnd->SCp.ptr) {
-               dma_unmap_single(&pci_dev->dev,
-                                (dma_addr_t)((unsigned long)cmnd->SCp.ptr),
-                                SENSE_SIZE, DMA_FROM_DEVICE);
-               cmnd->SCp.ptr = NULL;
-       }
-
-       /* request buffer */
-       if (cmnd->use_sg) {
-               dma_unmap_single(&pci_dev->dev, cmnd->SCp.dma_handle,
-                                sizeof(struct SG_Struc) * TOTAL_SG_ENTRY,
-                                DMA_BIDIRECTIONAL);
-
-               dma_unmap_sg(&pci_dev->dev, cmnd->request_buffer,
-                            cmnd->use_sg,
-                            cmnd->sc_data_direction);
-       } else if (cmnd->request_bufflen) {
-               dma_unmap_single(&pci_dev->dev, cmnd->SCp.dma_handle,
-                                cmnd->request_bufflen,
-                                cmnd->sc_data_direction);
-       }
-}
-
-/*****************************************************************************
- Function name  : i91uSCBPost
- Description    : This is callback routine be called when tulip finish one
-                       SCSI command.
- Input          : pHCB  -       Pointer to host adapter control block.
-                 pSCB  -       Pointer to SCSI control block.
- Output         : None.
- Return         : None.
-*****************************************************************************/
-static void i91uSCBPost(BYTE * pHcb, BYTE * pScb)
-{
-       struct scsi_cmnd *pSRB; /* Pointer to SCSI request block */
-       HCS *pHCB;
-       SCB *pSCB;
-
-       pHCB = (HCS *) pHcb;
-       pSCB = (SCB *) pScb;
-       if ((pSRB = pSCB->SCB_Srb) == 0) {
-               printk("i91uSCBPost: SRB pointer is empty\n");
-
-               tul_release_scb(pHCB, pSCB);    /* Release SCB for current channel */
-               return;
-       }
-       switch (pSCB->SCB_HaStat) {
-       case 0x0:
-       case 0xa:               /* Linked command complete without error and linked normally */
-       case 0xb:               /* Linked command complete without error interrupt generated */
-               pSCB->SCB_HaStat = 0;
-               break;
-
-       case 0x11:              /* Selection time out-The initiator selection or target
-                                  reselection was not complete within the SCSI Time out period */
-               pSCB->SCB_HaStat = DID_TIME_OUT;
-               break;
-
-       case 0x14:              /* Target bus phase sequence failure-An invalid bus phase or bus
-                                  phase sequence was requested by the target. The host adapter
-                                  will generate a SCSI Reset Condition, notifying the host with
-                                  a SCRD interrupt */
-               pSCB->SCB_HaStat = DID_RESET;
-               break;
-
-       case 0x1a:              /* SCB Aborted. 07/21/98 */
-               pSCB->SCB_HaStat = DID_ABORT;
-               break;
-
-       case 0x12:              /* Data overrun/underrun-The target attempted to transfer more data
-                                  than was allocated by the Data Length field or the sum of the
-                                  Scatter / Gather Data Length fields. */
-       case 0x13:              /* Unexpected bus free-The target dropped the SCSI BSY at an unexpected time. */
-       case 0x16:              /* Invalid SCB Operation Code. */
-
-       default:
-               printk("ini9100u: %x %x\n", pSCB->SCB_HaStat, pSCB->SCB_TaStat);
-               pSCB->SCB_HaStat = DID_ERROR;   /* Couldn't find any better */
-               break;
-       }
-
-       pSRB->result = pSCB->SCB_TaStat | (pSCB->SCB_HaStat << 16);
-
-       if (pSRB == NULL) {
-               printk("pSRB is NULL\n");
-       }
-
-       i91u_unmap_cmnd(pHCB->pci_dev, pSRB);
-       pSRB->scsi_done(pSRB);  /* Notify system DONE           */
-
-       tul_release_scb(pHCB, pSCB);    /* Release SCB for current channel */
-}
-
-/*
- * Release ressources
- */
-static int i91u_release(struct Scsi_Host *hreg)
-{
-       free_irq(hreg->irq, hreg);
-       release_region(hreg->io_port, 256);
-       return 0;
-}
-MODULE_LICENSE("Dual BSD/GPL");
-
-static struct scsi_host_template driver_template = {
-       .proc_name      = "INI9100U",
-       .name           = i91u_REVID,
-       .detect         = i91u_detect,
-       .release        = i91u_release,
-       .queuecommand   = i91u_queuecommand,
-//     .abort          = i91u_abort,
-//     .reset          = i91u_reset,
-       .eh_bus_reset_handler = i91u_bus_reset,
-       .bios_param     = i91u_biosparam,
-       .can_queue      = 1,
-       .this_id        = 1,
-       .sg_tablesize   = SG_ALL,
-       .cmd_per_lun    = 1,
-       .use_clustering = ENABLE_CLUSTERING,
-};
-#include "scsi_module.c"
-
+/**************************** EOF *********************************/