]> err.no Git - linux-2.6/blobdiff - drivers/scsi/advansys.c
[SCSI] advansys: Remove pci_slot_info
[linux-2.6] / drivers / scsi / advansys.c
index 5885ce4aad9a1758d8908a4bdcf2f6a311d17c3b..986c52a7b95e86388716e960887663ca70496b8b 100644 (file)
@@ -854,8 +854,6 @@ typedef unsigned char uchar;
 #define ERR      (-1)
 #define UW_ERR   (uint)(0xFFFF)
 #define isodd_word(val)   ((((uint)val) & (uint)0x0001) != 0)
-#define ASC_PCI_ID2FUNC(id)   (((id) >> 8) & 0x7)
-#define ASC_PCI_MKID(bus, dev, func) ((((dev) & 0x1F) << 11) | (((func) & 0x7) << 8) | ((bus) & 0xFF))
 
 #define  ASC_DVCLIB_CALL_DONE     (1)
 #define  ASC_DVCLIB_CALL_FAILED   (0)
@@ -1378,9 +1376,7 @@ typedef struct asc_dvc_cfg {
        uchar max_tag_qng[ASC_MAX_TID + 1];
        uchar *overrun_buf;
        uchar sdtr_period_offset[ASC_MAX_TID + 1];
-       ushort pci_slot_info;
        uchar adapter_info[6];
-       struct device *dev;
 } ASC_DVC_CFG;
 
 #define ASC_DEF_DVC_CNTL       0xFFFF
@@ -1405,17 +1401,12 @@ typedef struct asc_dvc_cfg {
 
 struct asc_dvc_var;            /* Forward Declaration. */
 
-typedef void (*ASC_ISR_CALLBACK) (struct asc_dvc_var *, ASC_QDONE_INFO *);
-typedef int (*ASC_EXE_CALLBACK) (struct asc_dvc_var *, ASC_SCSI_Q *);
-
 typedef struct asc_dvc_var {
        PortAddr iop_base;
        ushort err_code;
        ushort dvc_cntl;
        ushort bug_fix_cntl;
        ushort bus_type;
-       ASC_ISR_CALLBACK isr_callback;
-       ASC_EXE_CALLBACK exe_callback;
        ASC_SCSI_BIT_ID_TYPE init_sdtr;
        ASC_SCSI_BIT_ID_TYPE sdtr_done;
        ASC_SCSI_BIT_ID_TYPE use_tagged_qng;
@@ -1815,9 +1806,6 @@ static void AscEnableInterrupt(PortAddr);
 static void AscSetBank(PortAddr, uchar);
 static int AscResetChipAndScsiBus(ASC_DVC_VAR *);
 #ifdef CONFIG_ISA
-static ushort AscGetIsaDmaChannel(PortAddr);
-static ushort AscSetIsaDmaChannel(PortAddr, ushort);
-static uchar AscSetIsaDmaSpeed(PortAddr, uchar);
 static uchar AscGetIsaDmaSpeed(PortAddr);
 #endif /* CONFIG_ISA */
 static uchar AscReadLramByte(PortAddr, ushort);
@@ -1834,7 +1822,6 @@ static void AscMemDWordCopyPtrToLram(PortAddr, ushort, uchar *, int);
 static void AscMemWordCopyPtrFromLram(PortAddr, ushort, uchar *, int);
 static ushort AscInitAscDvcVar(ASC_DVC_VAR *);
 static ushort AscInitFromEEP(ASC_DVC_VAR *);
-static ushort AscInitFromAscDvcVar(ASC_DVC_VAR *);
 static ushort AscInitMicroCodeVar(ASC_DVC_VAR *);
 static int AscTestExternalLram(ASC_DVC_VAR *);
 static uchar AscMsgOutSDTR(ASC_DVC_VAR *, uchar, uchar);
@@ -1862,18 +1849,11 @@ static int AscIsrQDone(ASC_DVC_VAR *);
 static ushort AscGetEisaChipCfg(PortAddr);
 #endif /* CONFIG_ISA */
 static uchar AscGetChipScsiCtrl(PortAddr);
-static uchar AscSetChipScsiID(PortAddr, uchar);
 static uchar AscGetChipVersion(PortAddr, ushort);
-static ushort AscGetChipBusType(PortAddr);
 static ASC_DCNT AscLoadMicroCode(PortAddr, ushort, uchar *, ushort);
-static int AscFindSignature(PortAddr);
 static void AscToggleIRQAct(PortAddr);
-static uchar AscGetChipIRQ(PortAddr, ushort);
-static uchar AscSetChipIRQ(PortAddr, uchar, ushort);
-static ushort AscGetChipBiosAddress(PortAddr, ushort);
 static inline ulong DvcEnterCritical(void);
 static inline void DvcLeaveCritical(ulong);
-static ushort AscGetChipBiosAddress(PortAddr, ushort);
 static void DvcSleepMilliSecond(ASC_DCNT);
 static void DvcDelayNanoSecond(ASC_DVC_VAR *, ASC_DCNT);
 static void DvcPutScsiQ(PortAddr, ushort, uchar *, int);
@@ -1887,7 +1867,6 @@ static int AscSgListToQueue(int);
 #ifdef CONFIG_ISA
 static void AscEnableIsaDma(uchar);
 #endif /* CONFIG_ISA */
-static ASC_DCNT AscGetMaxDmaCount(ushort);
 static const char *advansys_info(struct Scsi_Host *shost);
 
 /*
@@ -2300,10 +2279,8 @@ typedef struct adveep_38C1600_config {
 #define BIOS_CTRL_AIPP_DIS           0x2000
 
 #define ADV_3550_MEMSIZE   0x2000      /* 8 KB Internal Memory */
-#define ADV_3550_IOLEN     0x40        /* I/O Port Range in bytes */
 
 #define ADV_38C0800_MEMSIZE  0x4000    /* 16 KB Internal Memory */
-#define ADV_38C0800_IOLEN    0x100     /* I/O Port Range in bytes */
 
 /*
  * XXX - Since ASC38C1600 Rev.3 has a local RAM failure issue, there is
@@ -2313,8 +2290,6 @@ typedef struct adveep_38C1600_config {
  * #define ADV_38C1600_MEMSIZE  0x8000L   * 32 KB Internal Memory *
  */
 #define ADV_38C1600_MEMSIZE  0x4000    /* 16 KB Internal Memory */
-#define ADV_38C1600_IOLEN    0x100     /* I/O Port Range 256 bytes */
-#define ADV_38C1600_MEMLEN   0x1000    /* Memory Range 4KB bytes */
 
 /*
  * Byte I/O register address from base of 'iop_base'.
@@ -2836,24 +2811,14 @@ typedef struct adv_dvc_cfg {
        ushort control_flag;    /* Microcode Control Flag */
        ushort mcode_date;      /* Microcode date */
        ushort mcode_version;   /* Microcode version */
-       ushort pci_slot_info;   /* high byte device/function number */
-       /* bits 7-3 device num., bits 2-0 function num. */
-       /* low byte bus num. */
        ushort serial1;         /* EEPROM serial number word 1 */
        ushort serial2;         /* EEPROM serial number word 2 */
        ushort serial3;         /* EEPROM serial number word 3 */
-       struct device *dev;     /* pointer to the pci dev structure for this board */
 } ADV_DVC_CFG;
 
 struct adv_dvc_var;
 struct adv_scsi_req_q;
 
-typedef void (*ADV_ISR_CALLBACK)
- (struct adv_dvc_var *, struct adv_scsi_req_q *);
-
-typedef void (*ADV_ASYNC_CALLBACK)
- (struct adv_dvc_var *, uchar);
-
 /*
  * Adapter operation variable structure.
  *
@@ -2870,8 +2835,6 @@ typedef struct adv_dvc_var {
        AdvPortAddr iop_base;   /* I/O port address */
        ushort err_code;        /* fatal error code */
        ushort bios_ctrl;       /* BIOS control word, EEPROM word 12 */
-       ADV_ISR_CALLBACK isr_callback;
-       ADV_ASYNC_CALLBACK async_callback;
        ushort wdtr_able;       /* try WDTR for a device */
        ushort sdtr_able;       /* try SDTR for a device */
        ushort ultra_able;      /* try SDTR Ultra speed for a device */
@@ -3015,7 +2978,6 @@ static void DvcDelayMicroSecond(ADV_DVC_VAR *, ushort);
  */
 static int AdvExeScsiQueue(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *);
 static int AdvISR(ADV_DVC_VAR *);
-static int AdvInitGetConfig(ADV_DVC_VAR *);
 static int AdvInitAsc3550Driver(ADV_DVC_VAR *);
 static int AdvInitAsc38C0800Driver(ADV_DVC_VAR *);
 static int AdvInitAsc38C1600Driver(ADV_DVC_VAR *);
@@ -3612,6 +3574,7 @@ typedef struct adv_req {
  * field. It is guaranteed to be allocated from DMA-able memory.
  */
 typedef struct asc_board {
+       struct device *dev;
        int id;                 /* Board Id */
        uint flags;             /* Board flags */
        union {
@@ -3663,6 +3626,10 @@ typedef struct asc_board {
        ushort bios_codelen;    /* BIOS Code Segment Length. */
 } asc_board_t;
 
+#define adv_dvc_to_board(adv_dvc) container_of(adv_dvc, struct asc_board, \
+                                                       dvc_var.adv_dvc_var)
+#define adv_dvc_to_pdev(adv_dvc) to_pci_dev(adv_dvc_to_board(adv_dvc)->dev)
+
 /* Number of boards detected in system. */
 static int asc_board_count;
 
@@ -3689,9 +3656,6 @@ 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 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);
 static void asc_enqueue(asc_queue_t *, REQP, int);
 static REQP asc_dequeue(asc_queue_t *, int);
 static REQP asc_dequeue_list(asc_queue_t *, REQP *, int);
@@ -3710,10 +3674,6 @@ static int asc_prt_adv_board_info(struct Scsi_Host *, char *, int);
 static int asc_prt_line(char *, int, char *fmt, ...);
 #endif /* CONFIG_PROC_FS */
 
-/* Declaration for Asc Library internal functions referenced by driver. */
-static int AscFindSignature(PortAddr);
-static ushort AscGetEEPConfig(PortAddr, ASCEEP_CONFIG *, ushort);
-
 /* Statistics function prototypes. */
 #ifdef ADVANSYS_STATS
 #ifdef CONFIG_PROC_FS
@@ -3822,8 +3782,7 @@ advansys_proc_info(struct Scsi_Host *shost, char *buffer, char **start,
                cp = boardp->prtbuf;
                cplen = asc_prt_adv_bios(shost, cp, ASC_PRTBUF_SIZE);
                ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
-               cnt =
-                   asc_proc_copy(advoffset, offset, curbuf, leftlen, cp,
+               cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp,
                                  cplen);
                totcnt += cnt;
                leftlen -= cnt;
@@ -3910,11 +3869,10 @@ advansys_proc_info(struct Scsi_Host *shost, char *buffer, char **start,
        for (tgt_id = 0; tgt_id <= ADV_MAX_TID; tgt_id++) {
                cp = boardp->prtbuf;
                cplen = asc_prt_target_stats(shost, tgt_id, cp,
-                                                       ASC_PRTBUF_SIZE);
+                                            ASC_PRTBUF_SIZE);
                ASC_ASSERT(cplen <= ASC_PRTBUF_SIZE);
-               cnt =
-                   asc_proc_copy(advoffset, offset, curbuf, leftlen, cp,
-                                 cplen);
+               cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp,
+                                   cplen);
                totcnt += cnt;
                leftlen -= cnt;
                if (leftlen == 0) {
@@ -3969,7 +3927,6 @@ static const char *advansys_info(struct Scsi_Host *shost)
        ASC_DVC_VAR *asc_dvc_varp;
        ADV_DVC_VAR *adv_dvc_varp;
        char *busname;
-       int iolen;
        char *widename = NULL;
 
        boardp = ASC_BOARDP(shost);
@@ -3983,13 +3940,12 @@ static const char *advansys_info(struct Scsi_Host *shost)
                        } else {
                                busname = "ISA";
                        }
-                       /* Don't reference 'shost->n_io_port'; It may be truncated. */
                        sprintf(info,
                                "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X, DMA 0x%X",
                                ASC_VERSION, busname,
                                (ulong)shost->io_port,
-                               (ulong)shost->io_port + boardp->asc_n_io_port -
-                               1, shost->irq, shost->dma_channel);
+                               (ulong)shost->io_port + ASC_IOADR_GAP - 1,
+                               shost->irq, shost->dma_channel);
                } else {
                        if (asc_dvc_varp->bus_type & ASC_IS_VL) {
                                busname = "VL";
@@ -4004,17 +3960,15 @@ static const char *advansys_info(struct Scsi_Host *shost)
                                }
                        } else {
                                busname = "?";
-                               ASC_PRINT2
-                                   ("advansys_info: board %d: unknown bus type %d\n",
-                                    boardp->id, asc_dvc_varp->bus_type);
+                               ASC_PRINT2("advansys_info: board %d: unknown "
+                                          "bus type %d\n", boardp->id,
+                                          asc_dvc_varp->bus_type);
                        }
-                       /* Don't reference 'shost->n_io_port'; It may be truncated. */
                        sprintf(info,
                                "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X",
-                               ASC_VERSION, busname,
-                               (ulong)shost->io_port,
-                               (ulong)shost->io_port + boardp->asc_n_io_port -
-                               1, shost->irq);
+                               ASC_VERSION, busname, (ulong)shost->io_port,
+                               (ulong)shost->io_port + ASC_IOADR_GAP - 1,
+                               shost->irq);
                }
        } else {
                /*
@@ -4026,19 +3980,16 @@ static const char *advansys_info(struct Scsi_Host *shost)
                 */
                adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
                if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
-                       iolen = ADV_3550_IOLEN;
                        widename = "Ultra-Wide";
                } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
-                       iolen = ADV_38C0800_IOLEN;
                        widename = "Ultra2-Wide";
                } else {
-                       iolen = ADV_38C1600_IOLEN;
                        widename = "Ultra3-Wide";
                }
                sprintf(info,
                        "AdvanSys SCSI %s: PCI %s: PCIMEM 0x%lX-0x%lX, IRQ 0x%X",
                        ASC_VERSION, widename, (ulong)adv_dvc_varp->iop_base,
-                       (ulong)adv_dvc_varp->iop_base + iolen - 1, shost->irq);
+                       (ulong)adv_dvc_varp->iop_base + boardp->asc_n_io_port - 1, shost->irq);
        }
        ASC_ASSERT(strlen(info) < ASC_INFO_SIZE);
        ASC_DBG(1, "advansys_info: end\n");
@@ -4193,18 +4144,16 @@ static int advansys_reset(struct scsi_cmnd *scp)
 
                /* Refer to ASC_IERR_* defintions for meaning of 'err_code'. */
                if (asc_dvc_varp->err_code) {
-                       ASC_PRINT2
-                           ("advansys_reset: board %d: SCSI bus reset error: 0x%x\n",
-                            boardp->id, asc_dvc_varp->err_code);
+                       ASC_PRINT2("advansys_reset: board %d: SCSI bus reset "
+                                  "error: 0x%x\n", boardp->id,
+                                  asc_dvc_varp->err_code);
                        ret = FAILED;
                } else if (status) {
-                       ASC_PRINT2
-                           ("advansys_reset: board %d: SCSI bus reset warning: 0x%x\n",
-                            boardp->id, status);
+                       ASC_PRINT2("advansys_reset: board %d: SCSI bus reset "
+                                  "warning: 0x%x\n", boardp->id, status);
                } else {
-                       ASC_PRINT1
-                           ("advansys_reset: board %d: SCSI bus reset successful.\n",
-                            boardp->id);
+                       ASC_PRINT1("advansys_reset: board %d: SCSI bus reset "
+                                  "successful.\n", boardp->id);
                }
 
                ASC_DBG(1, "advansys_reset: after AscInitAsc1000Driver()\n");
@@ -4225,15 +4174,13 @@ static int advansys_reset(struct scsi_cmnd *scp)
                ASC_DBG(1, "advansys_reset: before AdvResetChipAndSB()\n");
                switch (AdvResetChipAndSB(adv_dvc_varp)) {
                case ASC_TRUE:
-                       ASC_PRINT1
-                           ("advansys_reset: board %d: SCSI bus reset successful.\n",
-                            boardp->id);
+                       ASC_PRINT1("advansys_reset: board %d: SCSI bus reset "
+                                  "successful.\n", boardp->id);
                        break;
                case ASC_FALSE:
                default:
-                       ASC_PRINT1
-                           ("advansys_reset: board %d: SCSI bus reset error.\n",
-                            boardp->id);
+                       ASC_PRINT1("advansys_reset: board %d: SCSI bus reset "
+                                  "error.\n", boardp->id);
                        ret = FAILED;
                        break;
                }
@@ -4254,8 +4201,8 @@ static int advansys_reset(struct scsi_cmnd *scp)
         * is returned in 'last_scp'.
         */
        if (done_scp == NULL) {
-               done_scp =
-                   asc_dequeue_list(&boardp->active, &last_scp, ASC_TID_ALL);
+               done_scp = asc_dequeue_list(&boardp->active, &last_scp,
+                                           ASC_TID_ALL);
                for (tscp = done_scp; tscp; tscp = REQPNEXT(tscp)) {
                        tscp->result = HOST_BYTE(DID_RESET);
                }
@@ -4281,8 +4228,8 @@ static int advansys_reset(struct scsi_cmnd *scp)
         * to DID_RESET.
         */
        if (done_scp == NULL) {
-               done_scp =
-                   asc_dequeue_list(&boardp->waiting, &last_scp, ASC_TID_ALL);
+               done_scp = asc_dequeue_list(&boardp->waiting, &last_scp,
+                                           ASC_TID_ALL);
                for (tscp = done_scp; tscp; tscp = REQPNEXT(tscp)) {
                        tscp->result = HOST_BYTE(DID_RESET);
                }
@@ -4313,9 +4260,8 @@ static int advansys_reset(struct scsi_cmnd *scp)
        /*
         * Complete all the 'done_scp' requests.
         */
-       if (done_scp != NULL) {
+       if (done_scp)
                asc_scsi_done_list(done_scp);
-       }
 
        ASC_DBG1(1, "advansys_reset: ret %d\n", ret);
 
@@ -4705,7 +4651,6 @@ static void asc_scsi_done_list(struct scsi_cmnd *scp)
        ASC_DBG(2, "asc_scsi_done_list: begin\n");
        while (scp != NULL) {
                asc_board_t *boardp;
-               struct device *dev;
 
                ASC_DBG1(3, "asc_scsi_done_list: scp 0x%lx\n", (ulong)scp);
                tscp = REQPNEXT(scp);
@@ -4713,17 +4658,12 @@ static void asc_scsi_done_list(struct scsi_cmnd *scp)
 
                boardp = ASC_BOARDP(scp->device->host);
 
-               if (ASC_NARROW_BOARD(boardp))
-                       dev = boardp->dvc_cfg.asc_dvc_cfg.dev;
-               else
-                       dev = boardp->dvc_cfg.adv_dvc_cfg.dev;
-
                if (scp->use_sg)
-                       dma_unmap_sg(dev,
+                       dma_unmap_sg(boardp->dev,
                                     (struct scatterlist *)scp->request_buffer,
                                     scp->use_sg, scp->sc_data_direction);
                else if (scp->request_bufflen)
-                       dma_unmap_single(dev, scp->SCp.dma_handle,
+                       dma_unmap_single(boardp->dev, scp->SCp.dma_handle,
                                         scp->request_bufflen,
                                         scp->sc_data_direction);
 
@@ -4829,33 +4769,33 @@ static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
                case ASC_NOERROR:
                        ASC_STATS(scp->device->host, exe_noerror);
                        /*
-                        * Increment monotonically increasing per device successful
-                        * request counter. Wrapping doesn't matter.
+                        * Increment monotonically increasing per device
+                        * successful request counter. Wrapping doesn't matter.
                         */
                        boardp->reqcnt[scp->device->id]++;
                        asc_enqueue(&boardp->active, scp, ASC_BACK);
-                       ASC_DBG(1,
-                               "asc_execute_scsi_cmnd: AscExeScsiQueue(), ASC_NOERROR\n");
+                       ASC_DBG(1, "asc_execute_scsi_cmnd: AscExeScsiQueue(), "
+                               "ASC_NOERROR\n");
                        break;
                case ASC_BUSY:
                        /*
-                        * Caller will enqueue request on the target's waiting queue
-                        * and retry later.
+                        * Caller will enqueue request on the target's waiting
+                        * queue and retry later.
                         */
                        ASC_STATS(scp->device->host, exe_busy);
                        break;
                case ASC_ERROR:
-                       ASC_PRINT2
-                           ("asc_execute_scsi_cmnd: board %d: AscExeScsiQueue() ASC_ERROR, err_code 0x%x\n",
-                            boardp->id, asc_dvc_varp->err_code);
+                       ASC_PRINT2("asc_execute_scsi_cmnd: board %d: "
+                               "AscExeScsiQueue() ASC_ERROR, err_code 0x%x\n",
+                               boardp->id, asc_dvc_varp->err_code);
                        ASC_STATS(scp->device->host, exe_error);
                        scp->result = HOST_BYTE(DID_ERROR);
                        asc_enqueue(&boardp->done, scp, ASC_BACK);
                        break;
                default:
-                       ASC_PRINT2
-                           ("asc_execute_scsi_cmnd: board %d: AscExeScsiQueue() unknown, err_code 0x%x\n",
-                            boardp->id, asc_dvc_varp->err_code);
+                       ASC_PRINT2("asc_execute_scsi_cmnd: board %d: "
+                               "AscExeScsiQueue() unknown, err_code 0x%x\n",
+                               boardp->id, asc_dvc_varp->err_code);
                        ASC_STATS(scp->device->host, exe_unknown);
                        scp->result = HOST_BYTE(DID_ERROR);
                        asc_enqueue(&boardp->done, scp, ASC_BACK);
@@ -4875,20 +4815,21 @@ static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
                 */
                switch (adv_build_req(boardp, scp, &adv_scsiqp)) {
                case ASC_NOERROR:
-                       ASC_DBG(3,
-                               "asc_execute_scsi_cmnd: adv_build_req ASC_NOERROR\n");
+                       ASC_DBG(3, "asc_execute_scsi_cmnd: adv_build_req "
+                               "ASC_NOERROR\n");
                        break;
                case ASC_BUSY:
-                       ASC_DBG(1,
-                               "asc_execute_scsi_cmnd: adv_build_req ASC_BUSY\n");
+                       ASC_DBG(1, "asc_execute_scsi_cmnd: adv_build_req "
+                               "ASC_BUSY\n");
                        /*
-                        * If busy is returned the request has not been enqueued.
-                        * It will be enqueued by the caller on the target's waiting
-                        * queue and retried later.
+                        * If busy is returned the request has not been
+                        * enqueued.  It will be enqueued by the caller on the
+                        * target's waiting queue and retried later.
                         *
-                        * The asc_stats fields 'adv_build_noreq' and 'adv_build_nosg'
-                        * count wide board busy conditions. They are updated in
-                        * adv_build_req and adv_get_sglist, respectively.
+                        * The asc_stats fields 'adv_build_noreq' and
+                        * 'adv_build_nosg' count wide board busy conditions.
+                        * They are updated in adv_build_req and
+                        * adv_get_sglist, respectively.
                         */
                        return ASC_BUSY;
                case ASC_ERROR:
@@ -4898,8 +4839,8 @@ static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
                         * by the caller.
                         */
                default:
-                       ASC_DBG(1,
-                               "asc_execute_scsi_cmnd: adv_build_req ASC_ERROR\n");
+                       ASC_DBG(1, "asc_execute_scsi_cmnd: adv_build_req "
+                               "ASC_ERROR\n");
                        ASC_STATS(scp->device->host, build_error);
                        return ASC_ERROR;
                }
@@ -4912,33 +4853,33 @@ static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
                case ASC_NOERROR:
                        ASC_STATS(scp->device->host, exe_noerror);
                        /*
-                        * Increment monotonically increasing per device successful
-                        * request counter. Wrapping doesn't matter.
+                        * Increment monotonically increasing per device
+                        * successful request counter. Wrapping doesn't matter.
                         */
                        boardp->reqcnt[scp->device->id]++;
                        asc_enqueue(&boardp->active, scp, ASC_BACK);
-                       ASC_DBG(1,
-                               "asc_execute_scsi_cmnd: AdvExeScsiQueue(), ASC_NOERROR\n");
+                       ASC_DBG(1, "asc_execute_scsi_cmnd: AdvExeScsiQueue(), "
+                               "ASC_NOERROR\n");
                        break;
                case ASC_BUSY:
                        /*
-                        * Caller will enqueue request on the target's waiting queue
-                        * and retry later.
+                        * Caller will enqueue request on the target's waiting
+                        * queue and retry later.
                         */
                        ASC_STATS(scp->device->host, exe_busy);
                        break;
                case ASC_ERROR:
-                       ASC_PRINT2
-                           ("asc_execute_scsi_cmnd: board %d: AdvExeScsiQueue() ASC_ERROR, err_code 0x%x\n",
-                            boardp->id, adv_dvc_varp->err_code);
+                       ASC_PRINT2("asc_execute_scsi_cmnd: board %d: "
+                               "AdvExeScsiQueue() ASC_ERROR, err_code 0x%x\n",
+                               boardp->id, adv_dvc_varp->err_code);
                        ASC_STATS(scp->device->host, exe_error);
                        scp->result = HOST_BYTE(DID_ERROR);
                        asc_enqueue(&boardp->done, scp, ASC_BACK);
                        break;
                default:
-                       ASC_PRINT2
-                           ("asc_execute_scsi_cmnd: board %d: AdvExeScsiQueue() unknown, err_code 0x%x\n",
-                            boardp->id, adv_dvc_varp->err_code);
+                       ASC_PRINT2("asc_execute_scsi_cmnd: board %d: "
+                               "AdvExeScsiQueue() unknown, err_code 0x%x\n",
+                               boardp->id, adv_dvc_varp->err_code);
                        ASC_STATS(scp->device->host, exe_unknown);
                        scp->result = HOST_BYTE(DID_ERROR);
                        asc_enqueue(&boardp->done, scp, ASC_BACK);
@@ -4961,8 +4902,6 @@ static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
  */
 static int asc_build_req(asc_board_t *boardp, struct scsi_cmnd *scp)
 {
-       struct device *dev = boardp->dvc_cfg.asc_dvc_cfg.dev;
-
        /*
         * Mutually exclusive access is required to 'asc_scsi_q' and
         * 'asc_sg_head' until after the request is started.
@@ -4981,9 +4920,9 @@ static int asc_build_req(asc_board_t *boardp, struct scsi_cmnd *scp)
         * is supported.
         */
        if (scp->cmd_len > ASC_MAX_CDB_LEN) {
-               ASC_PRINT3
-                   ("asc_build_req: board %d: cmd_len %d > ASC_MAX_CDB_LEN  %d\n",
-                    boardp->id, scp->cmd_len, ASC_MAX_CDB_LEN);
+               ASC_PRINT3("asc_build_req: board %d: cmd_len %d > "
+                       "ASC_MAX_CDB_LEN %d\n", boardp->id, scp->cmd_len,
+                       ASC_MAX_CDB_LEN);
                scp->result = HOST_BYTE(DID_ERROR);
                asc_enqueue(&boardp->done, scp, ASC_BACK);
                return ASC_ERROR;
@@ -5026,7 +4965,7 @@ static int asc_build_req(asc_board_t *boardp, struct scsi_cmnd *scp)
                 */
                ASC_STATS(scp->device->host, cont_cnt);
                scp->SCp.dma_handle = scp->request_bufflen ?
-                   dma_map_single(dev, scp->request_buffer,
+                   dma_map_single(boardp->dev, scp->request_buffer,
                                   scp->request_bufflen,
                                   scp->sc_data_direction) : 0;
                asc_scsi_q.q1.data_addr = cpu_to_le32(scp->SCp.dma_handle);
@@ -5044,15 +4983,14 @@ static int asc_build_req(asc_board_t *boardp, struct scsi_cmnd *scp)
                struct scatterlist *slp;
 
                slp = (struct scatterlist *)scp->request_buffer;
-               use_sg =
-                   dma_map_sg(dev, slp, scp->use_sg, scp->sc_data_direction);
+               use_sg = dma_map_sg(boardp->dev, slp, scp->use_sg,
+                                   scp->sc_data_direction);
 
                if (use_sg > scp->device->host->sg_tablesize) {
-                       ASC_PRINT3
-                           ("asc_build_req: board %d: use_sg %d > sg_tablesize %d\n",
-                            boardp->id, use_sg,
-                            scp->device->host->sg_tablesize);
-                       dma_unmap_sg(dev, slp, scp->use_sg,
+                       ASC_PRINT3("asc_build_req: board %d: use_sg %d > "
+                                  "sg_tablesize %d\n", boardp->id, use_sg,
+                                  scp->device->host->sg_tablesize);
+                       dma_unmap_sg(boardp->dev, slp, scp->use_sg,
                                     scp->sc_data_direction);
                        scp->result = HOST_BYTE(DID_ERROR);
                        asc_enqueue(&boardp->done, scp, ASC_BACK);
@@ -5113,7 +5051,6 @@ adv_build_req(asc_board_t *boardp, struct scsi_cmnd *scp,
        ADV_SCSI_REQ_Q *scsiqp;
        int i;
        int ret;
-       struct device *dev = boardp->dvc_cfg.adv_dvc_cfg.dev;
 
        /*
         * Allocate an adv_req_t structure from the board to execute
@@ -5200,7 +5137,7 @@ adv_build_req(asc_board_t *boardp, struct scsi_cmnd *scp,
                if (scp->request_bufflen) {
                        scsiqp->vdata_addr = scp->request_buffer;
                        scp->SCp.dma_handle =
-                           dma_map_single(dev, scp->request_buffer,
+                           dma_map_single(boardp->dev, scp->request_buffer,
                                           scp->request_bufflen,
                                           scp->sc_data_direction);
                } else {
@@ -5221,22 +5158,21 @@ adv_build_req(asc_board_t *boardp, struct scsi_cmnd *scp,
                int use_sg;
 
                slp = (struct scatterlist *)scp->request_buffer;
-               use_sg =
-                   dma_map_sg(dev, slp, scp->use_sg, scp->sc_data_direction);
+               use_sg = dma_map_sg(boardp->dev, slp, scp->use_sg,
+                                   scp->sc_data_direction);
 
                if (use_sg > ADV_MAX_SG_LIST) {
-                       ASC_PRINT3
-                           ("adv_build_req: board %d: use_sg %d > ADV_MAX_SG_LIST %d\n",
-                            boardp->id, use_sg,
-                            scp->device->host->sg_tablesize);
-                       dma_unmap_sg(dev, slp, scp->use_sg,
+                       ASC_PRINT3("adv_build_req: board %d: use_sg %d > "
+                                  "ADV_MAX_SG_LIST %d\n", boardp->id, use_sg,
+                                  scp->device->host->sg_tablesize);
+                       dma_unmap_sg(boardp->dev, slp, scp->use_sg,
                                     scp->sc_data_direction);
                        scp->result = HOST_BYTE(DID_ERROR);
                        asc_enqueue(&boardp->done, scp, ASC_BACK);
 
                        /*
-                        * Free the 'adv_req_t' structure by adding it back to the
-                        * board free list.
+                        * Free the 'adv_req_t' structure by adding it back
+                        * to the board free list.
                         */
                        reqp->next_reqp = boardp->adv_reqp;
                        boardp->adv_reqp = reqp;
@@ -5244,12 +5180,11 @@ adv_build_req(asc_board_t *boardp, struct scsi_cmnd *scp,
                        return ASC_ERROR;
                }
 
-               if ((ret =
-                    adv_get_sglist(boardp, reqp, scp,
-                                   use_sg)) != ADV_SUCCESS) {
+               ret = adv_get_sglist(boardp, reqp, scp, use_sg);
+               if (ret != ADV_SUCCESS) {
                        /*
-                        * Free the adv_req_t structure by adding it back to the
-                        * board free list.
+                        * Free the adv_req_t structure by adding it back to
+                        * the board free list.
                         */
                        reqp->next_reqp = boardp->adv_reqp;
                        boardp->adv_reqp = reqp;
@@ -6722,10 +6657,7 @@ static int asc_prt_driver_conf(struct Scsi_Host *shost, char *cp, int cplen)
                           boardp->asc_n_io_port);
        ASC_PRT_NEXT();
 
-       /* 'shost->n_io_port' may be truncated because it is only one byte. */
-       len = asc_prt_line(cp, leftlen,
-                          " io_port 0x%x, n_io_port 0x%x\n",
-                          shost->io_port, shost->n_io_port);
+       len = asc_prt_line(cp, leftlen, " io_port 0x%x\n", shost->io_port);
        ASC_PRT_NEXT();
 
        if (ASC_NARROW_BOARD(boardp)) {
@@ -7330,27 +7262,27 @@ DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
  * Return the BIOS address of the adapter at the specified
  * I/O port and with the specified bus type.
  */
-static ushort __devinit AscGetChipBiosAddress(PortAddr iop_base, ushort bus_type)
+static unsigned short __devinit
+AscGetChipBiosAddress(PortAddr iop_base, unsigned short bus_type)
 {
-       ushort cfg_lsw;
-       ushort bios_addr;
+       unsigned short cfg_lsw;
+       unsigned short bios_addr;
 
        /*
         * The PCI BIOS is re-located by the motherboard BIOS. Because
         * of this the driver can not determine where a PCI BIOS is
         * loaded and executes.
         */
-       if (bus_type & ASC_IS_PCI) {
-               return (0);
-       }
+       if (bus_type & ASC_IS_PCI)
+               return 0;
+
 #ifdef CONFIG_ISA
        if ((bus_type & ASC_IS_EISA) != 0) {
                cfg_lsw = AscGetEisaChipCfg(iop_base);
                cfg_lsw &= 0x000F;
-               bios_addr = (ushort)(ASC_BIOS_MIN_ADDR +
-                                    (cfg_lsw * ASC_BIOS_BANK_SIZE));
-               return (bios_addr);
-       }                       /* if */
+               bios_addr = ASC_BIOS_MIN_ADDR + cfg_lsw * ASC_BIOS_BANK_SIZE;
+               return bios_addr;
+       }
 #endif /* CONFIG_ISA */
 
        cfg_lsw = AscGetChipCfgLsw(iop_base);
@@ -7358,13 +7290,10 @@ static ushort __devinit AscGetChipBiosAddress(PortAddr iop_base, ushort bus_type
        /*
         *  ISA PnP uses the top bit as the 32K BIOS flag
         */
-       if (bus_type == ASC_IS_ISAPNP) {
+       if (bus_type == ASC_IS_ISAPNP)
                cfg_lsw &= 0x7FFF;
-       }
-       /* if */
-       bios_addr = (ushort)(((cfg_lsw >> 12) * ASC_BIOS_BANK_SIZE) +
-                            ASC_BIOS_MIN_ADDR);
-       return (bios_addr);
+       bios_addr = ASC_BIOS_MIN_ADDR + (cfg_lsw >> 12) * ASC_BIOS_BANK_SIZE;
+       return bios_addr;
 }
 
 /*
@@ -7620,8 +7549,8 @@ static void asc_prt_scsi_host(struct Scsi_Host *s)
        printk(" host_busy %u, host_no %d, last_reset %d,\n",
               s->host_busy, s->host_no, (unsigned)s->last_reset);
 
-       printk(" base 0x%lx, io_port 0x%lx, n_io_port %u, irq 0x%x,\n",
-              (ulong)s->base, (ulong)s->io_port, s->n_io_port, s->irq);
+       printk(" base 0x%lx, io_port 0x%lx, irq 0x%x,\n",
+              (ulong)s->base, (ulong)s->io_port, s->irq);
 
        printk(" dma_channel %d, this_id %d, can_queue %d,\n",
               s->dma_channel, s->this_id, s->can_queue);
@@ -7661,10 +7590,8 @@ static void asc_prt_scsi_cmnd(struct scsi_cmnd *s)
 
        printk(" timeout_per_command %d\n", s->timeout_per_command);
 
-       printk
-           (" scsi_done 0x%lx, done 0x%lx, host_scribble 0x%lx, result 0x%x\n",
-            (ulong)s->scsi_done, (ulong)s->done, (ulong)s->host_scribble,
-            s->result);
+       printk(" scsi_done 0x%p, done 0x%p, host_scribble 0x%p, result 0x%x\n",
+               s->scsi_done, s->done, s->host_scribble, s->result);
 
        printk(" tag %u, pid %u\n", (unsigned)s->tag, (unsigned)s->pid);
 }
@@ -7676,34 +7603,30 @@ static void asc_prt_asc_dvc_var(ASC_DVC_VAR *h)
 {
        printk("ASC_DVC_VAR at addr 0x%lx\n", (ulong)h);
 
-       printk
-           (" iop_base 0x%x, err_code 0x%x, dvc_cntl 0x%x, bug_fix_cntl %d,\n",
-            h->iop_base, h->err_code, h->dvc_cntl, h->bug_fix_cntl);
+       printk(" iop_base 0x%x, err_code 0x%x, dvc_cntl 0x%x, bug_fix_cntl "
+              "%d,\n", h->iop_base, h->err_code, h->dvc_cntl, h->bug_fix_cntl);
 
-       printk
-           (" bus_type %d, isr_callback 0x%lx, exe_callback 0x%lx, init_sdtr 0x%x,\n",
-            h->bus_type, (ulong)h->isr_callback, (ulong)h->exe_callback,
-            (unsigned)h->init_sdtr);
+       printk(" bus_type %d, init_sdtr 0x%x,\n", h->bus_type,
+               (unsigned)h->init_sdtr);
 
-       printk
-           (" sdtr_done 0x%x, use_tagged_qng 0x%x, unit_not_ready 0x%x, chip_no 0x%x,\n",
-            (unsigned)h->sdtr_done, (unsigned)h->use_tagged_qng,
-            (unsigned)h->unit_not_ready, (unsigned)h->chip_no);
+       printk(" sdtr_done 0x%x, use_tagged_qng 0x%x, unit_not_ready 0x%x, "
+              "chip_no 0x%x,\n", (unsigned)h->sdtr_done,
+              (unsigned)h->use_tagged_qng, (unsigned)h->unit_not_ready,
+              (unsigned)h->chip_no);
 
-       printk
-           (" queue_full_or_busy 0x%x, start_motor 0x%x, scsi_reset_wait %u,\n",
-            (unsigned)h->queue_full_or_busy, (unsigned)h->start_motor,
-            (unsigned)h->scsi_reset_wait);
+       printk(" queue_full_or_busy 0x%x, start_motor 0x%x, scsi_reset_wait "
+              "%u,\n", (unsigned)h->queue_full_or_busy,
+              (unsigned)h->start_motor, (unsigned)h->scsi_reset_wait);
 
-       printk
-           (" is_in_int %u, max_total_qng %u, cur_total_qng %u, in_critical_cnt %u,\n",
-            (unsigned)h->is_in_int, (unsigned)h->max_total_qng,
-            (unsigned)h->cur_total_qng, (unsigned)h->in_critical_cnt);
+       printk(" is_in_int %u, max_total_qng %u, cur_total_qng %u, "
+              "in_critical_cnt %u,\n", (unsigned)h->is_in_int,
+              (unsigned)h->max_total_qng, (unsigned)h->cur_total_qng,
+              (unsigned)h->in_critical_cnt);
 
-       printk
-           (" last_q_shortage %u, init_state 0x%x, no_scam 0x%x, pci_fix_asyn_xfer 0x%x,\n",
-            (unsigned)h->last_q_shortage, (unsigned)h->init_state,
-            (unsigned)h->no_scam, (unsigned)h->pci_fix_asyn_xfer);
+       printk(" last_q_shortage %u, init_state 0x%x, no_scam 0x%x, "
+              "pci_fix_asyn_xfer 0x%x,\n", (unsigned)h->last_q_shortage,
+              (unsigned)h->init_state, (unsigned)h->no_scam,
+              (unsigned)h->pci_fix_asyn_xfer);
 
        printk(" cfg 0x%lx, irq_no 0x%x\n", (ulong)h->cfg, (unsigned)h->irq_no);
 }
@@ -7839,8 +7762,7 @@ static void asc_prt_adv_dvc_cfg(ADV_DVC_CFG *h)
        printk("  mcode_version 0x%x, pci_device_id 0x%x, lib_version %u\n",
               h->mcode_version, to_pci_dev(h->dev)->device, h->lib_version);
 
-       printk("  control_flag 0x%x, pci_slot_info 0x%x\n",
-              h->control_flag, h->pci_slot_info);
+       printk("  control_flag 0x%x\n", h->control_flag);
 }
 
 /*
@@ -8007,55 +7929,28 @@ static uchar __devinit AscSetChipScsiID(PortAddr iop_base, uchar new_host_id)
        return (AscGetChipScsiID(iop_base));
 }
 
-static uchar __devinit AscGetChipScsiCtrl(PortAddr iop_base)
+static unsigned char __devinit AscGetChipScsiCtrl(PortAddr iop_base)
 {
-       uchar sc;
+       unsigned char sc;
 
        AscSetBank(iop_base, 1);
        sc = inp(iop_base + IOP_REG_SC);
        AscSetBank(iop_base, 0);
-       return (sc);
+       return sc;
 }
 
-static uchar __devinit AscGetChipVersion(PortAddr iop_base, ushort bus_type)
+static unsigned char __devinit
+AscGetChipVersion(PortAddr iop_base, unsigned short bus_type)
 {
-       if ((bus_type & ASC_IS_EISA) != 0) {
+       if (bus_type & ASC_IS_EISA) {
                PortAddr eisa_iop;
-               uchar revision;
+               unsigned char revision;
                eisa_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
                    (PortAddr) ASC_EISA_REV_IOP_MASK;
                revision = inp(eisa_iop);
-               return ((uchar)((ASC_CHIP_MIN_VER_EISA - 1) + revision));
-       }
-       return (AscGetChipVerNo(iop_base));
-}
-
-static ushort __devinit AscGetChipBusType(PortAddr iop_base)
-{
-       ushort chip_ver;
-
-       chip_ver = AscGetChipVerNo(iop_base);
-       if ((chip_ver >= ASC_CHIP_MIN_VER_VL)
-           && (chip_ver <= ASC_CHIP_MAX_VER_VL)
-           ) {
-               if (((iop_base & 0x0C30) == 0x0C30)
-                   || ((iop_base & 0x0C50) == 0x0C50)
-                   ) {
-                       return (ASC_IS_EISA);
-               }
-               return (ASC_IS_VL);
-       }
-       if ((chip_ver >= ASC_CHIP_MIN_VER_ISA) &&
-           (chip_ver <= ASC_CHIP_MAX_VER_ISA)) {
-               if (chip_ver >= ASC_CHIP_MIN_VER_ISA_PNP) {
-                       return (ASC_IS_ISAPNP);
-               }
-               return (ASC_IS_ISA);
-       } else if ((chip_ver >= ASC_CHIP_MIN_VER_PCI) &&
-                  (chip_ver <= ASC_CHIP_MAX_VER_PCI)) {
-               return (ASC_IS_PCI);
+               return ASC_CHIP_MIN_VER_EISA - 1 + revision;
        }
-       return (0);
+       return AscGetChipVerNo(iop_base);
 }
 
 static ASC_DCNT
@@ -8716,10 +8611,8 @@ static int AscIsrQDone(ASC_DVC_VAR *asc_dvc)
        ASC_QDONE_INFO scsiq_buf;
        ASC_QDONE_INFO *scsiq;
        int false_overrun;
-       ASC_ISR_CALLBACK asc_isr_callback;
 
        iop_base = asc_dvc->iop_base;
-       asc_isr_callback = asc_dvc->isr_callback;
        n_q_used = 1;
        scsiq = (ASC_QDONE_INFO *)&scsiq_buf;
        done_q_tail = (uchar)AscGetVarDoneQTail(iop_base);
@@ -8831,7 +8724,7 @@ static int AscIsrQDone(ASC_DVC_VAR *asc_dvc)
                                }
                        }
                        if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
-                               (*asc_isr_callback) (asc_dvc, scsiq);
+                               asc_isr_callback(asc_dvc, scsiq);
                        } else {
                                if ((AscReadLramByte(iop_base,
                                                     (ushort)(q_addr + (ushort)
@@ -8849,7 +8742,7 @@ static int AscIsrQDone(ASC_DVC_VAR *asc_dvc)
                        AscSetLibErrorCode(asc_dvc, ASCQ_ERR_Q_STATUS);
  FATAL_ERR_QDONE:
                        if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
-                               (*asc_isr_callback) (asc_dvc, scsiq);
+                               asc_isr_callback(asc_dvc, scsiq);
                        }
                        return (0x80);
                }
@@ -8875,9 +8768,7 @@ static int AscISR(ASC_DVC_VAR *asc_dvc)
                return int_pending;
        }
 
-       if (((asc_dvc->init_state & ASC_INIT_STATE_END_LOAD_MC) == 0)
-           || (asc_dvc->isr_callback == 0)
-           ) {
+       if ((asc_dvc->init_state & ASC_INIT_STATE_END_LOAD_MC) == 0) {
                return (ERR);
        }
        if (asc_dvc->in_critical_cnt != 0) {
@@ -9276,7 +9167,6 @@ static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq)
        int disable_syn_offset_one_fix;
        int i;
        ASC_PADDR addr;
-       ASC_EXE_CALLBACK asc_exe_callback;
        ushort sg_entry_cnt = 0;
        ushort sg_entry_cnt_minus_one = 0;
        uchar target_ix;
@@ -9290,7 +9180,6 @@ static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq)
 
        iop_base = asc_dvc->iop_base;
        sg_head = scsiq->sg_head;
-       asc_exe_callback = asc_dvc->exe_callback;
        if (asc_dvc->err_code != 0)
                return (ERR);
        if (scsiq == (ASC_SCSI_Q *)0L) {
@@ -9451,9 +9340,6 @@ static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq)
                             AscSendScsiQueue(asc_dvc, scsiq,
                                              n_q_required)) == 1) {
                                asc_dvc->in_critical_cnt--;
-                               if (asc_exe_callback != 0) {
-                                       (*asc_exe_callback) (asc_dvc, scsiq);
-                               }
                                DvcLeaveCritical(last_int_level);
                                return (sta);
                        }
@@ -9499,9 +9385,6 @@ static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq)
                        if ((sta = AscSendScsiQueue(asc_dvc, scsiq,
                                                    n_q_required)) == 1) {
                                asc_dvc->in_critical_cnt--;
-                               if (asc_exe_callback != 0) {
-                                       (*asc_exe_callback) (asc_dvc, scsiq);
-                               }
                                DvcLeaveCritical(last_int_level);
                                return (sta);
                        }
@@ -10281,39 +10164,29 @@ static ushort __devinit AscInitGetConfig(ASC_DVC_VAR *asc_dvc)
                warn_code |= AscInitAscDvcVar(asc_dvc);
                warn_code |= AscInitFromEEP(asc_dvc);
                asc_dvc->init_state |= ASC_INIT_STATE_END_GET_CFG;
-               if (asc_dvc->scsi_reset_wait > ASC_MAX_SCSI_RESET_WAIT) {
+               if (asc_dvc->scsi_reset_wait > ASC_MAX_SCSI_RESET_WAIT)
                        asc_dvc->scsi_reset_wait = ASC_MAX_SCSI_RESET_WAIT;
-               }
        } else {
                asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
        }
-       return (warn_code);
+       return warn_code;
 }
 
-static ushort __devinit AscInitSetConfig(ASC_DVC_VAR *asc_dvc)
+static unsigned short __devinit
+AscInitSetConfig(struct pci_dev *pdev, ASC_DVC_VAR *asc_dvc)
 {
-       ushort warn_code = 0;
+       PortAddr iop_base = asc_dvc->iop_base;
+       unsigned short cfg_msw;
+       unsigned short warn_code = 0;
 
        asc_dvc->init_state |= ASC_INIT_STATE_BEG_SET_CFG;
        if (asc_dvc->err_code != 0)
-               return (UW_ERR);
-       if (AscFindSignature(asc_dvc->iop_base)) {
-               warn_code |= AscInitFromAscDvcVar(asc_dvc);
-               asc_dvc->init_state |= ASC_INIT_STATE_END_SET_CFG;
-       } else {
+               return UW_ERR;
+       if (!AscFindSignature(asc_dvc->iop_base)) {
                asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
+               return 0;
        }
-       return (warn_code);
-}
-
-static ushort __devinit AscInitFromAscDvcVar(ASC_DVC_VAR *asc_dvc)
-{
-       PortAddr iop_base;
-       ushort cfg_msw;
-       ushort warn_code;
 
-       iop_base = asc_dvc->iop_base;
-       warn_code = 0;
        cfg_msw = AscGetChipCfgMsw(iop_base);
        if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
                cfg_msw &= (~(ASC_CFG_MSW_CLR_MASK));
@@ -10336,7 +10209,6 @@ static ushort __devinit AscInitFromAscDvcVar(ASC_DVC_VAR *asc_dvc)
        }
 #ifdef CONFIG_PCI
        if (asc_dvc->bus_type & ASC_IS_PCI) {
-               struct pci_dev *pdev = to_pci_dev(asc_dvc->cfg->dev);
                cfg_msw &= 0xFFC0;
                AscSetChipCfgMsw(iop_base, cfg_msw);
                if ((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) {
@@ -10366,7 +10238,9 @@ static ushort __devinit AscInitFromAscDvcVar(ASC_DVC_VAR *asc_dvc)
                AscSetIsaDmaSpeed(iop_base, asc_dvc->cfg->isa_dma_speed);
        }
 #endif /* CONFIG_ISA */
-       return (warn_code);
+
+       asc_dvc->init_state |= ASC_INIT_STATE_END_SET_CFG;
+       return warn_code;
 }
 
 static ushort AscInitAsc1000Driver(ASC_DVC_VAR *asc_dvc)
@@ -10498,12 +10372,12 @@ static ushort __devinit AscInitAscDvcVar(ASC_DVC_VAR *asc_dvc)
        }
 
        asc_dvc->cfg->isa_dma_speed = ASC_DEF_ISA_DMA_SPEED;
-       if (AscGetChipBusType(iop_base) == ASC_IS_ISAPNP) {
-               AscSetChipIFC(iop_base, IFC_INIT_DEFAULT);
-               asc_dvc->bus_type = ASC_IS_ISAPNP;
-       }
 #ifdef CONFIG_ISA
        if ((asc_dvc->bus_type & ASC_IS_ISA) != 0) {
+               if (chip_version >= ASC_CHIP_MIN_VER_ISA_PNP) {
+                       AscSetChipIFC(iop_base, IFC_INIT_DEFAULT);
+                       asc_dvc->bus_type = ASC_IS_ISAPNP;
+               }
                asc_dvc->cfg->isa_dma_channel =
                    (uchar)AscGetIsaDmaChannel(iop_base);
        }
@@ -13670,11 +13544,11 @@ static ADVEEP_38C1600_CONFIG ADVEEP_38C1600_Config_Field_IsChar __devinitdata =
  * For a non-fatal error return a warning code. If there are no warnings
  * then 0 is returned.
  */
-static int __devinit AdvInitGetConfig(ADV_DVC_VAR *asc_dvc)
+static int __devinit
+AdvInitGetConfig(struct pci_dev *pdev, ADV_DVC_VAR *asc_dvc)
 {
        unsigned short warn_code = 0;
        AdvPortAddr iop_base = asc_dvc->iop_base;
-       struct pci_dev *pdev = to_pci_dev(asc_dvc->cfg->dev);
        u16 cmd;
        int status;
 
@@ -15324,6 +15198,7 @@ static int AdvInitAsc38C1600Driver(ADV_DVC_VAR *asc_dvc)
         * ready to be 'ored' into SCSI_CFG1.
         */
        if ((asc_dvc->cfg->termination & TERM_SE) == 0) {
+               struct pci_dev *pdev = adv_dvc_to_pdev(asc_dvc);
                /* SE automatic termination control is enabled. */
                switch (scsi_cfg1 & C_DET_SE) {
                        /* TERM_SE_HI: on, TERM_SE_LO: on */
@@ -15334,7 +15209,7 @@ static int AdvInitAsc38C1600Driver(ADV_DVC_VAR *asc_dvc)
                        break;
 
                case 0x0:
-                       if (ASC_PCI_ID2FUNC(asc_dvc->cfg->pci_slot_info) == 0) {
+                       if (PCI_FUNC(pdev->devfn) == 0) {
                                /* Function 0 - TERM_SE_HI: off, TERM_SE_LO: off */
                        } else {
                                /* Function 1 - TERM_SE_HI: on, TERM_SE_LO: off */
@@ -15940,15 +15815,14 @@ static int __devinit AdvInitFrom38C1600EEP(ADV_DVC_VAR *asc_dvc)
         */
        if (AdvGet38C1600EEPConfig(iop_base, &eep_config) !=
            eep_config.check_sum) {
+               struct pci_dev *pdev = adv_dvc_to_pdev(asc_dvc);
                warn_code |= ASC_WARN_EEPROM_CHKSUM;
 
                /*
                 * Set EEPROM default values.
                 */
                for (i = 0; i < sizeof(ADVEEP_38C1600_CONFIG); i++) {
-                       if (i == 1
-                           && ASC_PCI_ID2FUNC(asc_dvc->cfg->pci_slot_info) !=
-                           0) {
+                       if (i == 1 && PCI_FUNC(pdev->devfn) != 0) {
                                /*
                                 * Set Function 1 EEPROM Word 0 MSB
                                 *
@@ -16839,7 +16713,7 @@ static int AdvISR(ADV_DVC_VAR *asc_dvc)
 
        /*
         * Notify the driver of an asynchronous microcode condition by
-        * calling the ADV_DVC_VAR.async_callback function. The function
+        * calling the adv_async_callback function. The function
         * is passed the microcode ASC_MC_INTRB_CODE byte value.
         */
        if (int_stat & ADV_INTR_STATUS_INTRB) {
@@ -16861,9 +16735,7 @@ static int AdvISR(ADV_DVC_VAR *asc_dvc)
                        }
                }
 
-               if (asc_dvc->async_callback != 0) {
-                       (*asc_dvc->async_callback) (asc_dvc, intrb_code);
-               }
+               adv_async_callback(asc_dvc, intrb_code);
        }
 
        /*
@@ -16921,7 +16793,7 @@ static int AdvISR(ADV_DVC_VAR *asc_dvc)
                 * the ADV_SCSI_REQ_Q pointer to its callback function.
                 */
                scsiq->a_flag |= ADV_SCSIQ_DONE;
-               (*asc_dvc->isr_callback) (asc_dvc, scsiq);
+               adv_isr_callback(asc_dvc, scsiq);
                /*
                 * Note: After the driver callback function is called, 'scsiq'
                 * can no longer be referenced.
@@ -17148,20 +17020,15 @@ advansys_board_found(int iop, struct device *dev, int bus_type)
        ASC_DVC_VAR *asc_dvc_varp = NULL;
        ADV_DVC_VAR *adv_dvc_varp = NULL;
        int share_irq;
-       int iolen = 0;
-       ADV_PADDR pci_memory_address;
        int warn_code, err_code;
        int ret;
 
        /*
-        * Adapter found.
-        *
         * Register the adapter, get its configuration, and
         * initialize it.
         */
        ASC_DBG(2, "advansys_board_found: scsi_host_alloc()\n");
        shost = scsi_host_alloc(&advansys_template, sizeof(asc_board_t));
-
        if (!shost)
                return NULL;
 
@@ -17169,9 +17036,8 @@ advansys_board_found(int iop, struct device *dev, int bus_type)
        boardp = ASC_BOARDP(shost);
        memset(boardp, 0, sizeof(asc_board_t));
        boardp->id = asc_board_count++;
-
-       /* Initialize spinlock. */
        spin_lock_init(&boardp->lock);
+       boardp->dev = dev;
 
        /*
         * Handle both narrow and wide boards.
@@ -17197,15 +17063,12 @@ advansys_board_found(int iop, struct device *dev, int bus_type)
                asc_dvc_varp->cfg = &boardp->dvc_cfg.asc_dvc_cfg;
                asc_dvc_varp->cfg->overrun_buf = &overrun_buf[0];
                asc_dvc_varp->iop_base = iop;
-               asc_dvc_varp->isr_callback = asc_isr_callback;
        } else {
+#ifdef CONFIG_PCI
                ASC_DBG(1, "advansys_board_found: wide board\n");
                adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
                adv_dvc_varp->drv_ptr = boardp;
                adv_dvc_varp->cfg = &boardp->dvc_cfg.adv_dvc_cfg;
-               adv_dvc_varp->isr_callback = adv_isr_callback;
-               adv_dvc_varp->async_callback = adv_async_callback;
-#ifdef CONFIG_PCI
                if (pdev->device == PCI_DEVICE_ID_ASP_ABP940UW) {
                        ASC_DBG(1, "advansys_board_found: ASC-3550\n");
                        adv_dvc_varp->chip_type = ADV_CHIP_ASC3550;
@@ -17216,46 +17079,20 @@ advansys_board_found(int iop, struct device *dev, int bus_type)
                        ASC_DBG(1, "advansys_board_found: ASC-38C1600\n");
                        adv_dvc_varp->chip_type = ADV_CHIP_ASC38C1600;
                }
-#endif /* CONFIG_PCI */
 
-               /*
-                * Map the board's registers into virtual memory for
-                * PCI slave access. Only memory accesses are used to
-                * access the board's registers.
-                *
-                * Note: The PCI register base address is not always
-                * page aligned, but the address passed to ioremap()
-                * must be page aligned. It is guaranteed that the
-                * PCI register base address will not cross a page
-                * boundary.
-                */
-               if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
-                       iolen = ADV_3550_IOLEN;
-               } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
-                       iolen = ADV_38C0800_IOLEN;
-               } else {
-                       iolen = ADV_38C1600_IOLEN;
-               }
-#ifdef CONFIG_PCI
-               pci_memory_address = pci_resource_start(pdev, 1);
-               ASC_DBG1(1,
-                        "advansys_board_found: pci_memory_address: 0x%lx\n",
-                        (ulong)pci_memory_address);
-               if ((boardp->ioremap_addr =
-                    ioremap(pci_memory_address & PAGE_MASK, PAGE_SIZE)) == 0) {
+               boardp->asc_n_io_port = pci_resource_len(pdev, 1);
+               boardp->ioremap_addr = ioremap(pci_resource_start(pdev, 1),
+                                              boardp->asc_n_io_port);
+               if (!boardp->ioremap_addr) {
                        ASC_PRINT3
                            ("advansys_board_found: board %d: ioremap(%x, %d) returned NULL\n",
-                            boardp->id, pci_memory_address, iolen);
+                            boardp->id, pci_resource_start(pdev, 1),
+                            boardp->asc_n_io_port);
                        goto err_shost;
                }
-               ASC_DBG1(1, "advansys_board_found: ioremap_addr: 0x%lx\n",
-                        (ulong)boardp->ioremap_addr);
-               adv_dvc_varp->iop_base = (AdvPortAddr)
-                   (boardp->ioremap_addr +
-                    (pci_memory_address - (pci_memory_address & PAGE_MASK)));
+               adv_dvc_varp->iop_base = (AdvPortAddr)boardp->ioremap_addr
                ASC_DBG1(1, "advansys_board_found: iop_base: 0x%lx\n",
                         adv_dvc_varp->iop_base);
-#endif /* CONFIG_PCI */
 
                /*
                 * Even though it isn't used to access wide boards, other
@@ -17264,9 +17101,10 @@ advansys_board_found(int iop, struct device *dev, int bus_type)
                 */
                boardp->ioport = iop;
 
-               ASC_DBG2(1,
-                        "advansys_board_found: iopb_chip_id_1 0x%x, iopw_chip_id_0 0x%x\n",
-                        (ushort)inp(iop + 1), (ushort)inpw(iop));
+               ASC_DBG2(1, "advansys_board_found: iopb_chip_id_1 0x%x, "
+                        "iopw_chip_id_0 0x%x\n", (ushort)inp(iop + 1),
+                        (ushort)inpw(iop));
+#endif /* CONFIG_PCI */
        }
 
 #ifdef CONFIG_PROC_FS
@@ -17283,7 +17121,6 @@ advansys_board_found(int iop, struct device *dev, int bus_type)
 #endif /* CONFIG_PROC_FS */
 
        if (ASC_NARROW_BOARD(boardp)) {
-               asc_dvc_varp->cfg->dev = dev;
                /*
                 * Set the board bus type and PCI IRQ before
                 * calling AscInitGetConfig().
@@ -17306,10 +17143,6 @@ advansys_board_found(int iop, struct device *dev, int bus_type)
 #ifdef CONFIG_PCI
                case ASC_IS_PCI:
                        shost->irq = asc_dvc_varp->irq_no = pdev->irq;
-                       asc_dvc_varp->cfg->pci_slot_info =
-                           ASC_PCI_MKID(pdev->bus->number,
-                                        PCI_SLOT(pdev->devfn),
-                                        PCI_FUNC(pdev->devfn));
                        shost->unchecked_isa_dma = FALSE;
                        share_irq = IRQF_SHARED;
                        break;
@@ -17323,17 +17156,12 @@ advansys_board_found(int iop, struct device *dev, int bus_type)
                        break;
                }
        } else {
-               adv_dvc_varp->cfg->dev = dev;
                /*
                 * For Wide boards set PCI information before calling
                 * AdvInitGetConfig().
                 */
 #ifdef CONFIG_PCI
                shost->irq = adv_dvc_varp->irq_no = pdev->irq;
-               adv_dvc_varp->cfg->pci_slot_info =
-                   ASC_PCI_MKID(pdev->bus->number,
-                                PCI_SLOT(pdev->devfn),
-                                PCI_FUNC(pdev->devfn));
                shost->unchecked_isa_dma = FALSE;
                share_irq = IRQF_SHARED;
 #endif /* CONFIG_PCI */
@@ -17392,7 +17220,9 @@ advansys_board_found(int iop, struct device *dev, int bus_type)
                }
        } else {
                ASC_DBG(2, "advansys_board_found: AdvInitGetConfig()\n");
-               if ((ret = AdvInitGetConfig(adv_dvc_varp)) != 0) {
+
+               ret = AdvInitGetConfig(pdev, adv_dvc_varp);
+               if (ret != 0) {
                        ASC_PRINT2
                            ("AdvInitGetConfig: board %d: warning: 0x%x\n",
                             boardp->id, ret);
@@ -17448,7 +17278,7 @@ advansys_board_found(int iop, struct device *dev, int bus_type)
                 * Modify board configuration.
                 */
                ASC_DBG(2, "advansys_board_found: AscInitSetConfig()\n");
-               switch (ret = AscInitSetConfig(asc_dvc_varp)) {
+               switch (ret = AscInitSetConfig(pdev, asc_dvc_varp)) {
                case 0: /* No error. */
                        break;
                case ASC_WARN_IO_PORT_ROTATE:
@@ -17590,11 +17420,6 @@ advansys_board_found(int iop, struct device *dev, int bus_type)
                 */
                boardp->init_tidmask |=
                    ADV_TID_TO_TIDMASK(adv_dvc_varp->chip_scsi_id);
-
-               /*
-                * Finish initializing the 'Scsi_Host' structure.
-                */
-               shost->irq = adv_dvc_varp->irq_no;
        }
 
        /*
@@ -17624,7 +17449,6 @@ advansys_board_found(int iop, struct device *dev, int bus_type)
                 * PCI Memory Mapped I/O.
                 */
                shost->io_port = iop;
-               boardp->asc_n_io_port = iolen;
 
                shost->this_id = adv_dvc_varp->chip_scsi_id;
 
@@ -17632,15 +17456,6 @@ advansys_board_found(int iop, struct device *dev, int bus_type)
                shost->can_queue = adv_dvc_varp->max_host_qng;
        }
 
-       /*
-        * 'n_io_port' currently is one byte.
-        *
-        * Set a value to 'n_io_port', but never referenced it because
-        * it may be truncated.
-        */
-       shost->n_io_port = boardp->asc_n_io_port <= 255 ?
-           boardp->asc_n_io_port : 255;
-
        /*
         * Following v1.3.89, 'cmd_per_lun' is no longer needed
         * and should be set to zero.