static int qla2x00_fw_ready(scsi_qla_host_t *);
 static int qla2x00_configure_hba(scsi_qla_host_t *);
 static int qla2x00_nvram_config(scsi_qla_host_t *);
-static void qla2x00_init_tgt_map(scsi_qla_host_t *);
 static int qla2x00_configure_loop(scsi_qla_host_t *);
 static int qla2x00_configure_local_loop(scsi_qla_host_t *);
 static void qla2x00_update_fcport(scsi_qla_host_t *, fc_port_t *);
-static void qla2x00_lun_discovery(scsi_qla_host_t *, fc_port_t *);
-static int qla2x00_rpt_lun_discovery(scsi_qla_host_t *, fc_port_t *,
-    inq_cmd_rsp_t *, dma_addr_t);
-static int qla2x00_report_lun(scsi_qla_host_t *, fc_port_t *);
-static fc_lun_t *qla2x00_cfg_lun(scsi_qla_host_t *, fc_port_t *, uint16_t,
-    inq_cmd_rsp_t *, dma_addr_t);
-static fc_lun_t * qla2x00_add_lun(fc_port_t *, uint16_t);
-static int qla2x00_inquiry(scsi_qla_host_t *, fc_port_t *, uint16_t,
-    inq_cmd_rsp_t *, dma_addr_t);
 static int qla2x00_configure_fabric(scsi_qla_host_t *);
 static int qla2x00_find_all_fabric_devs(scsi_qla_host_t *, struct list_head *);
 static int qla2x00_device_resync(scsi_qla_host_t *);
 static int qla2x00_fabric_dev_login(scsi_qla_host_t *, fc_port_t *,
     uint16_t *);
-static void qla2x00_config_os(scsi_qla_host_t *ha);
-static uint16_t qla2x00_fcport_bind(scsi_qla_host_t *ha, fc_port_t *fcport);
-static os_lun_t * qla2x00_fclun_bind(scsi_qla_host_t *, fc_port_t *,
-    fc_lun_t *);
-static void qla2x00_lun_free(scsi_qla_host_t *, uint16_t, uint16_t);
 
 static int qla2x00_restart_isp(scsi_qla_host_t *);
 static void qla2x00_reset_adapter(scsi_qla_host_t *);
-static os_tgt_t *qla2x00_tgt_alloc(scsi_qla_host_t *, uint16_t);
-static os_lun_t *qla2x00_lun_alloc(scsi_qla_host_t *, uint16_t, uint16_t);
 
 /****************************************************************************/
 /*                QLogic ISP2x00 Hardware Support Functions.                */
 
        qla2x00_reset_chip(ha);
 
-       /* Initialize target map database. */
-       qla2x00_init_tgt_map(ha);
-
        qla_printk(KERN_INFO, ha, "Configure NVRAM parameters...\n");
        qla2x00_nvram_config(ha);
 
        return (rval);
 }
 
-/*
-* qla2x00_init_tgt_map
-*      Initializes target map.
-*
-* Input:
-*      ha = adapter block pointer.
-*
-* Output:
-*      TGT_Q initialized
-*/
-static void
-qla2x00_init_tgt_map(scsi_qla_host_t *ha)
-{
-       uint32_t t;
-
-       for (t = 0; t < MAX_TARGETS; t++)
-               TGT_Q(ha, t) = (os_tgt_t *)NULL;
-}
-
 /**
  * qla2x00_alloc_fcport() - Allocate a generic fcport.
  * @ha: HA context
        fcport->iodesc_idx_sent = IODESC_INVALID_INDEX;
        atomic_set(&fcport->state, FCS_UNCONFIGURED);
        fcport->flags = FCF_RLC_SUPPORT;
-       INIT_LIST_HEAD(&fcport->fcluns);
 
        return (fcport);
 }
                    test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)) {
                        rval = QLA_FUNCTION_FAILED;
                } else {
-                       qla2x00_config_os(ha);
                        atomic_set(&ha->loop_state, LOOP_READY);
 
                        DEBUG(printk("scsi(%ld): LOOP READY\n", ha->host_no));
        if (fcport->flags & FCF_TAPE_PRESENT) {
                spin_lock_irqsave(&ha->hardware_lock, flags);
                for (index = 1; index < MAX_OUTSTANDING_COMMANDS; index++) {
+                       fc_port_t *sfcp;
+
                        if ((sp = ha->outstanding_cmds[index]) != 0) {
-                               if (sp->fclun->fcport == fcport) {
+                               sfcp = sp->fcport;
+                               if (sfcp == fcport) {
                                        atomic_set(&fcport->state, FCS_ONLINE);
                                        spin_unlock_irqrestore(
                                            &ha->hardware_lock, flags);
                spin_unlock_irqrestore(&ha->hardware_lock, flags);
        }
 
-       /* Do LUN discovery. */
        if (fcport->port_type == FCT_INITIATOR ||
-           fcport->port_type == FCT_BROADCAST) {
+           fcport->port_type == FCT_BROADCAST)
                fcport->device_type = TYPE_PROCESSOR;
-       } else {
-               qla2x00_lun_discovery(ha, fcport);
-       }
+
        atomic_set(&fcport->state, FCS_ONLINE);
+
        if (ha->flags.init_done)
                qla2x00_reg_remote_port(ha, fcport);
 }
 qla2x00_reg_remote_port(scsi_qla_host_t *ha, fc_port_t *fcport)
 {
        struct fc_rport_identifiers rport_ids;
+       struct fc_rport *rport;
 
        if (fcport->rport) {
                fc_remote_port_unblock(fcport->rport);
        if (fcport->port_type == FCT_TARGET)
                rport_ids.roles |= FC_RPORT_ROLE_FCP_TARGET;
 
-       fcport->rport = fc_remote_port_add(ha->host, 0, &rport_ids);
-       if (!fcport->rport)
+       fcport->rport = rport = fc_remote_port_add(ha->host, 0, &rport_ids);
+       if (!rport)
                qla_printk(KERN_WARNING, ha,
                    "Unable to allocate fc remote port!\n");
-}
-/*
- * qla2x00_lun_discovery
- *     Issue SCSI inquiry command for LUN discovery.
- *
- * Input:
- *     ha:             adapter state pointer.
- *     fcport:         FC port structure pointer.
- *
- * Context:
- *     Kernel context.
- */
-static void
-qla2x00_lun_discovery(scsi_qla_host_t *ha, fc_port_t *fcport)
-{
-       inq_cmd_rsp_t   *inq;
-       dma_addr_t      inq_dma;
-       uint16_t        lun;
-
-       inq = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &inq_dma);
-       if (inq == NULL) {
-               qla_printk(KERN_WARNING, ha,
-                   "Memory Allocation failed - INQ\n");
-               return;
-       }
 
-       /* Always add a fc_lun_t structure for lun 0 -- mid-layer requirement */
-       qla2x00_add_lun(fcport, 0);
-
-       /* If report LUN works, exit. */
-       if (qla2x00_rpt_lun_discovery(ha, fcport, inq, inq_dma) !=
-           QLA_SUCCESS) {
-               for (lun = 0; lun < ha->max_probe_luns; lun++) {
-                       /* Configure LUN. */
-                       qla2x00_cfg_lun(ha, fcport, lun, inq, inq_dma);
-               }
-       }
+       if (rport->scsi_target_id != -1 && rport->scsi_target_id < MAX_TARGETS)
+               fcport->os_target_id = rport->scsi_target_id;
 
-       dma_pool_free(ha->s_dma_pool, inq, inq_dma);
+       rport->dd_data = fcport;
 }
 
-/*
- * qla2x00_rpt_lun_discovery
- *     Issue SCSI report LUN command for LUN discovery.
- *
- * Input:
- *     ha:             adapter state pointer.
- *     fcport:         FC port structure pointer.
- *
- * Returns:
- *     qla2x00 local function return status code.
- *
- * Context:
- *     Kernel context.
- */
-static int
-qla2x00_rpt_lun_discovery(scsi_qla_host_t *ha, fc_port_t *fcport,
-    inq_cmd_rsp_t *inq, dma_addr_t inq_dma)
-{
-       int                     rval;
-       uint32_t                len, cnt;
-       uint16_t                lun;
-
-       /* Assume a failed status */
-       rval = QLA_FUNCTION_FAILED;
-
-       /* No point in continuing if the device doesn't support RLC */
-       if ((fcport->flags & FCF_RLC_SUPPORT) == 0)
-               return (rval);
-
-       rval = qla2x00_report_lun(ha, fcport);
-       if (rval != QLA_SUCCESS)
-               return (rval);
-
-       /* Configure LUN list. */
-       len = be32_to_cpu(ha->rlc_rsp->list.hdr.len);
-       len /= 8;
-       for (cnt = 0; cnt < len; cnt++) {
-               lun = CHAR_TO_SHORT(ha->rlc_rsp->list.lst[cnt].lsb,
-                   ha->rlc_rsp->list.lst[cnt].msb.b);
-
-               DEBUG3(printk("scsi(%ld): RLC lun = (%d)\n", ha->host_no, lun));
-
-               /* We only support 0 through MAX_LUNS-1 range */
-               if (lun < MAX_LUNS) {
-                       qla2x00_cfg_lun(ha, fcport, lun, inq, inq_dma);
-               }
-       }
-       atomic_set(&fcport->state, FCS_ONLINE);
-
-       return (rval);
-}
-
-/*
- * qla2x00_report_lun
- *     Issue SCSI report LUN command.
- *
- * Input:
- *     ha:             adapter state pointer.
- *     fcport:         FC port structure pointer.
- *
- * Returns:
- *     qla2x00 local function return status code.
- *
- * Context:
- *     Kernel context.
- */
-static int
-qla2x00_report_lun(scsi_qla_host_t *ha, fc_port_t *fcport)
-{
-       int rval;
-       uint16_t retries;
-       uint16_t comp_status;
-       uint16_t scsi_status;
-       rpt_lun_cmd_rsp_t *rlc;
-       dma_addr_t rlc_dma;
-
-       rval = QLA_FUNCTION_FAILED;
-       rlc = ha->rlc_rsp;
-       rlc_dma = ha->rlc_rsp_dma;
-
-       for (retries = 3; retries; retries--) {
-               memset(rlc, 0, sizeof(rpt_lun_cmd_rsp_t));
-               rlc->p.cmd.entry_type = COMMAND_A64_TYPE;
-               rlc->p.cmd.entry_count = 1;
-               SET_TARGET_ID(ha, rlc->p.cmd.target, fcport->loop_id);
-               rlc->p.cmd.control_flags =
-                   __constant_cpu_to_le16(CF_READ | CF_SIMPLE_TAG);
-               rlc->p.cmd.scsi_cdb[0] = REPORT_LUNS;
-               rlc->p.cmd.scsi_cdb[8] = MSB(sizeof(rpt_lun_lst_t));
-               rlc->p.cmd.scsi_cdb[9] = LSB(sizeof(rpt_lun_lst_t));
-               rlc->p.cmd.dseg_count = __constant_cpu_to_le16(1);
-               rlc->p.cmd.timeout = __constant_cpu_to_le16(10);
-               rlc->p.cmd.byte_count =
-                   __constant_cpu_to_le32(sizeof(rpt_lun_lst_t));
-               rlc->p.cmd.dseg_0_address[0] = cpu_to_le32(
-                   LSD(rlc_dma + sizeof(sts_entry_t)));
-               rlc->p.cmd.dseg_0_address[1] = cpu_to_le32(
-                   MSD(rlc_dma + sizeof(sts_entry_t)));
-               rlc->p.cmd.dseg_0_length =
-                   __constant_cpu_to_le32(sizeof(rpt_lun_lst_t));
-
-               rval = qla2x00_issue_iocb(ha, rlc, rlc_dma,
-                   sizeof(rpt_lun_cmd_rsp_t));
-
-               comp_status = le16_to_cpu(rlc->p.rsp.comp_status);
-               scsi_status = le16_to_cpu(rlc->p.rsp.scsi_status);
-
-               if (rval != QLA_SUCCESS || comp_status != CS_COMPLETE ||
-                   scsi_status & SS_CHECK_CONDITION) {
-
-                       /* Device underrun, treat as OK. */
-                       if (rval == QLA_SUCCESS &&
-                           comp_status == CS_DATA_UNDERRUN &&
-                           scsi_status & SS_RESIDUAL_UNDER) {
-
-                               rval = QLA_SUCCESS;
-                               break;
-                       }
-
-                       DEBUG(printk("scsi(%ld): RLC failed to issue iocb! "
-                           "fcport=[%04x/%p] rval=%x cs=%x ss=%x\n",
-                           ha->host_no, fcport->loop_id, fcport, rval,
-                           comp_status, scsi_status));
-
-                       rval = QLA_FUNCTION_FAILED;
-                       if (scsi_status & SS_CHECK_CONDITION) {
-                               DEBUG2(printk("scsi(%ld): RLC "
-                                   "SS_CHECK_CONDITION Sense Data "
-                                   "%02x %02x %02x %02x %02x %02x %02x %02x\n",
-                                   ha->host_no,
-                                   rlc->p.rsp.req_sense_data[0],
-                                   rlc->p.rsp.req_sense_data[1],
-                                   rlc->p.rsp.req_sense_data[2],
-                                   rlc->p.rsp.req_sense_data[3],
-                                   rlc->p.rsp.req_sense_data[4],
-                                   rlc->p.rsp.req_sense_data[5],
-                                   rlc->p.rsp.req_sense_data[6],
-                                   rlc->p.rsp.req_sense_data[7]));
-                               if (rlc->p.rsp.req_sense_data[2] ==
-                                   ILLEGAL_REQUEST) {
-                                       fcport->flags &= ~(FCF_RLC_SUPPORT);
-                                       break;
-                               }
-                       }
-               } else {
-                       break;
-               }
-       }
-
-       return (rval);
-}
-
-/*
- * qla2x00_cfg_lun
- *     Configures LUN into fcport LUN list.
- *
- * Input:
- *     fcport:         FC port structure pointer.
- *     lun:            LUN number.
- *
- * Context:
- *     Kernel context.
- */
-static fc_lun_t *
-qla2x00_cfg_lun(scsi_qla_host_t *ha, fc_port_t *fcport, uint16_t lun,
-    inq_cmd_rsp_t *inq, dma_addr_t inq_dma) 
-{
-       fc_lun_t *fclun;
-       uint8_t   device_type;
-
-       /* Bypass LUNs that failed. */
-       if (qla2x00_inquiry(ha, fcport, lun, inq, inq_dma) != QLA_SUCCESS) {
-               DEBUG2(printk("scsi(%ld): Failed inquiry - loop id=0x%04x "
-                   "lun=%d\n", ha->host_no, fcport->loop_id, lun));
-
-               return (NULL);
-       }
-       device_type = (inq->inq[0] & 0x1f);
-       switch (device_type) {
-       case TYPE_DISK:
-       case TYPE_PROCESSOR:
-       case TYPE_WORM:
-       case TYPE_ROM:
-       case TYPE_SCANNER:
-       case TYPE_MOD:
-       case TYPE_MEDIUM_CHANGER:
-       case TYPE_ENCLOSURE:
-       case 0x20:
-       case 0x0C:
-               break;
-       case TYPE_TAPE:
-               fcport->flags |= FCF_TAPE_PRESENT;
-               break;
-       default:
-               DEBUG2(printk("scsi(%ld): Unsupported lun type -- "
-                   "loop id=0x%04x lun=%d type=%x\n",
-                   ha->host_no, fcport->loop_id, lun, device_type));
-               return (NULL);
-       }
-
-       fcport->device_type = device_type;
-       fclun = qla2x00_add_lun(fcport, lun);
-
-       if (fclun != NULL) {
-               atomic_set(&fcport->state, FCS_ONLINE);
-       }
-
-       return (fclun);
-}
-
-/*
- * qla2x00_add_lun
- *     Adds LUN to database
- *
- * Input:
- *     fcport:         FC port structure pointer.
- *     lun:            LUN number.
- *
- * Context:
- *     Kernel context.
- */
-static fc_lun_t *
-qla2x00_add_lun(fc_port_t *fcport, uint16_t lun)
-{
-       int             found;
-       fc_lun_t        *fclun;
-
-       if (fcport == NULL) {
-               DEBUG(printk("scsi: Unable to add lun to NULL port\n"));
-               return (NULL);
-       }
-
-       /* Allocate LUN if not already allocated. */
-       found = 0;
-       list_for_each_entry(fclun, &fcport->fcluns, list) {
-               if (fclun->lun == lun) {
-                       found++;
-                       break;
-               }
-       }
-       if (found)
-               return (NULL);
-
-       fclun = kmalloc(sizeof(fc_lun_t), GFP_ATOMIC);
-       if (fclun == NULL) {
-               printk(KERN_WARNING
-                   "%s(): Memory Allocation failed - FCLUN\n",
-                   __func__);
-               return (NULL);
-       }
-
-       /* Setup LUN structure. */
-       memset(fclun, 0, sizeof(fc_lun_t));
-       fclun->lun = lun;
-       fclun->fcport = fcport;
-       fclun->o_fcport = fcport;
-       fclun->device_type = fcport->device_type;
-       atomic_set(&fcport->state, FCS_UNCONFIGURED);
-
-       list_add_tail(&fclun->list, &fcport->fcluns);
-
-       return (fclun);
-}
-
-/*
- * qla2x00_inquiry
- *     Issue SCSI inquiry command.
- *
- * Input:
- *     ha = adapter block pointer.
- *     fcport = FC port structure pointer.
- *
- * Return:
- *     0  - Success
- *  BIT_0 - error
- *
- * Context:
- *     Kernel context.
- */
-static int
-qla2x00_inquiry(scsi_qla_host_t *ha,
-    fc_port_t *fcport, uint16_t lun, inq_cmd_rsp_t *inq, dma_addr_t inq_dma)
-{
-       int rval;
-       uint16_t retries;
-       uint16_t comp_status;
-       uint16_t scsi_status;
-
-       rval = QLA_FUNCTION_FAILED;
-
-       for (retries = 3; retries; retries--) {
-               memset(inq, 0, sizeof(inq_cmd_rsp_t));
-               inq->p.cmd.entry_type = COMMAND_A64_TYPE;
-               inq->p.cmd.entry_count = 1;
-               inq->p.cmd.lun = cpu_to_le16(lun);
-               SET_TARGET_ID(ha, inq->p.cmd.target, fcport->loop_id);
-               inq->p.cmd.control_flags =
-                   __constant_cpu_to_le16(CF_READ | CF_SIMPLE_TAG);
-               inq->p.cmd.scsi_cdb[0] = INQUIRY;
-               inq->p.cmd.scsi_cdb[4] = INQ_DATA_SIZE;
-               inq->p.cmd.dseg_count = __constant_cpu_to_le16(1);
-               inq->p.cmd.timeout = __constant_cpu_to_le16(10);
-               inq->p.cmd.byte_count =
-                   __constant_cpu_to_le32(INQ_DATA_SIZE);
-               inq->p.cmd.dseg_0_address[0] = cpu_to_le32(
-                   LSD(inq_dma + sizeof(sts_entry_t)));
-               inq->p.cmd.dseg_0_address[1] = cpu_to_le32(
-                   MSD(inq_dma + sizeof(sts_entry_t)));
-               inq->p.cmd.dseg_0_length =
-                   __constant_cpu_to_le32(INQ_DATA_SIZE);
-
-               DEBUG5(printk("scsi(%ld): Lun Inquiry - fcport=[%04x/%p],"
-                   " lun (%d)\n",
-                   ha->host_no, fcport->loop_id, fcport, lun));
-
-               rval = qla2x00_issue_iocb(ha, inq, inq_dma,
-                   sizeof(inq_cmd_rsp_t));
-
-               comp_status = le16_to_cpu(inq->p.rsp.comp_status);
-               scsi_status = le16_to_cpu(inq->p.rsp.scsi_status);
-
-               DEBUG5(printk("scsi(%ld): lun (%d) inquiry - "
-                   "inq[0]= 0x%x, comp status 0x%x, scsi status 0x%x, "
-                   "rval=%d\n",
-                   ha->host_no, lun, inq->inq[0], comp_status, scsi_status,
-                   rval));
-
-               if (rval != QLA_SUCCESS || comp_status != CS_COMPLETE ||
-                   scsi_status & SS_CHECK_CONDITION) {
-
-                       DEBUG(printk("scsi(%ld): INQ failed to issue iocb! "
-                           "fcport=[%04x/%p] rval=%x cs=%x ss=%x\n",
-                           ha->host_no, fcport->loop_id, fcport, rval,
-                           comp_status, scsi_status));
-
-                       if (rval == QLA_SUCCESS)
-                               rval = QLA_FUNCTION_FAILED;
-
-                       if (scsi_status & SS_CHECK_CONDITION) {
-                               DEBUG2(printk("scsi(%ld): INQ "
-                                   "SS_CHECK_CONDITION Sense Data "
-                                   "%02x %02x %02x %02x %02x %02x %02x %02x\n",
-                                   ha->host_no,
-                                   inq->p.rsp.req_sense_data[0],
-                                   inq->p.rsp.req_sense_data[1],
-                                   inq->p.rsp.req_sense_data[2],
-                                   inq->p.rsp.req_sense_data[3],
-                                   inq->p.rsp.req_sense_data[4],
-                                   inq->p.rsp.req_sense_data[5],
-                                   inq->p.rsp.req_sense_data[6],
-                                   inq->p.rsp.req_sense_data[7]));
-                       }
-
-                       /* Device underrun drop LUN. */
-                       if (comp_status == CS_DATA_UNDERRUN &&
-                           scsi_status & SS_RESIDUAL_UNDER) {
-                               break;
-                       }
-               } else {
-                       break;
-               }
-       }
-
-       return (rval);
-}
-
-
 /*
  * qla2x00_configure_fabric
  *      Setup SNS devices with loop ID's.
                                break;
                        }
 
-                       /* Login and update database */
-                       qla2x00_fabric_dev_login(ha, fcport, &next_loopid);
-
                        /* Remove device from the new list and add it to DB */
                        list_del(&fcport->list);
                        list_add_tail(&fcport->list, &ha->fcports);
+
+                       /* Login and update database */
+                       qla2x00_fabric_dev_login(ha, fcport, &next_loopid);
                }
        } while (0);
 
                rescan_done = 1;
        }
        qla2x00_probe_for_all_luns(ha); 
-
-       /* Update OS target and lun structures if necessary. */
-       if (rescan_done) {
-               qla2x00_config_os(ha);
-       }
-}
-
-
-/*
- * qla2x00_config_os
- *     Setup OS target and LUN structures.
- *
- * Input:
- *     ha = adapter state pointer.
- *
- * Context:
- *     Kernel context.
- */
-static void
-qla2x00_config_os(scsi_qla_host_t *ha) 
-{
-       fc_port_t       *fcport;
-       fc_lun_t        *fclun;
-       os_tgt_t        *tq;
-       uint16_t        tgt;
-
-
-       for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
-               if ((tq = TGT_Q(ha, tgt)) == NULL)
-                       continue;
-
-               clear_bit(TQF_ONLINE, &tq->flags);
-       }
-
-       list_for_each_entry(fcport, &ha->fcports, list) {
-               if (atomic_read(&fcport->state) != FCS_ONLINE ||
-                   fcport->port_type == FCT_INITIATOR ||
-                   fcport->port_type == FCT_BROADCAST) {
-                       fcport->os_target_id = MAX_TARGETS;
-                       continue;
-               }
-
-               if (fcport->flags & FCF_FO_MASKED) {
-                       continue;
-               }
-
-               /* Bind FC port to OS target number. */
-               if (qla2x00_fcport_bind(ha, fcport) == MAX_TARGETS) {
-                       continue;
-               }
-
-               /* Bind FC LUN to OS LUN number. */
-               list_for_each_entry(fclun, &fcport->fcluns, list) {
-                       qla2x00_fclun_bind(ha, fcport, fclun);
-               }
-       }
-}
-
-/*
- * qla2x00_fcport_bind
- *     Locates a target number for FC port.
- *
- * Input:
- *     ha = adapter state pointer.
- *     fcport = FC port structure pointer.
- *
- * Returns:
- *     target number
- *
- * Context:
- *     Kernel context.
- */
-static uint16_t
-qla2x00_fcport_bind(scsi_qla_host_t *ha, fc_port_t *fcport) 
-{
-       int             found;
-       uint16_t        tgt;
-       os_tgt_t        *tq;
-
-       /* Check for persistent binding. */
-       for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
-               if ((tq = TGT_Q(ha, tgt)) == NULL)
-                       continue;
-
-               found = 0;
-               switch (ha->binding_type) {
-               case BIND_BY_PORT_ID:
-                       if (fcport->d_id.b24 == tq->d_id.b24) {
-                               memcpy(tq->node_name, fcport->node_name,
-                                   WWN_SIZE);
-                               memcpy(tq->port_name, fcport->port_name,
-                                   WWN_SIZE);
-                               found++;
-                       }
-                       break;
-               case BIND_BY_PORT_NAME:    
-                       if (memcmp(fcport->port_name, tq->port_name,
-                           WWN_SIZE) == 0) {
-                               /*
-                                * In case of persistent binding, update the
-                                * WWNN.
-                                */
-                               memcpy(tq->node_name, fcport->node_name,
-                                   WWN_SIZE);
-                               found++;
-                       }
-                       break;
-               }
-               if (found)
-                   break;      
-       }
-
-       /* TODO: honor the ConfigRequired flag */
-       if (tgt == MAX_TARGETS) {
-               /* Check if targetID 0 available. */
-               tgt = 0;
-
-               if (TGT_Q(ha, tgt) != NULL) {
-                       /* Locate first free target for device. */
-                       for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
-                               if (TGT_Q(ha, tgt) == NULL) {
-                                       break;
-                               }
-                       }
-               }
-               if (tgt != MAX_TARGETS) {
-                       if ((tq = qla2x00_tgt_alloc(ha, tgt)) != NULL) {
-                               memcpy(tq->node_name, fcport->node_name,
-                                   WWN_SIZE);
-                               memcpy(tq->port_name, fcport->port_name,
-                                   WWN_SIZE);
-                               tq->d_id.b24 = fcport->d_id.b24;
-                       }
-               }
-       }
-
-       /* Reset target numbers incase it changed. */
-       fcport->os_target_id = tgt;
-       if (tgt != MAX_TARGETS && tq != NULL) {
-               DEBUG2(printk("scsi(%ld): Assigning target ID=%02d @ %p to "
-                   "loop id=0x%04x, port state=0x%x, port down retry=%d\n",
-                   ha->host_no, tgt, tq, fcport->loop_id,
-                   atomic_read(&fcport->state),
-                   atomic_read(&fcport->port_down_timer)));
-
-               fcport->tgt_queue = tq;
-               fcport->flags |= FCF_PERSISTENT_BOUND;
-               tq->fcport = fcport;
-               set_bit(TQF_ONLINE, &tq->flags);
-               tq->port_down_retry_count = ha->port_down_retry_count;
-       }
-
-       if (tgt == MAX_TARGETS) {
-               qla_printk(KERN_WARNING, ha,
-                   "Unable to bind fcport, loop_id=%x\n", fcport->loop_id);
-       }
-
-       return (tgt);
-}
-
-/*
- * qla2x00_fclun_bind
- *     Binds all FC device LUNS to OS LUNS.
- *
- * Input:
- *     ha:             adapter state pointer.
- *     fcport:         FC port structure pointer.
- *
- * Returns:
- *     target number
- *
- * Context:
- *     Kernel context.
- */
-static os_lun_t *
-qla2x00_fclun_bind(scsi_qla_host_t *ha, fc_port_t *fcport, fc_lun_t *fclun)
-{
-       os_lun_t        *lq;
-       uint16_t        tgt;
-       uint16_t        lun;
-
-       tgt = fcport->os_target_id;
-       lun = fclun->lun;
-
-       /* Allocate LUNs */
-       if (lun >= MAX_LUNS) {
-               DEBUG2(printk("scsi(%ld): Unable to bind lun, invalid "
-                   "lun=(%x).\n", ha->host_no, lun));
-               return (NULL);
-       }
-
-       /* Always alloc LUN 0 so kernel will scan past LUN 0. */
-       if (lun != 0 && (EXT_IS_LUN_BIT_SET(&(fcport->lun_mask), lun))) {
-               return (NULL);
-       }
-
-       if ((lq = qla2x00_lun_alloc(ha, tgt, lun)) == NULL) {
-               qla_printk(KERN_WARNING, ha,
-                   "Unable to bind fclun, loop_id=%x lun=%x\n",
-                   fcport->loop_id, lun);
-               return (NULL);
-       }
-
-       lq->fclun = fclun;
-
-       return (lq);
-}
-
-/*
- * qla2x00_tgt_alloc
- *     Allocate and pre-initialize target queue.
- *
- * Input:
- *     ha = adapter block pointer.
- *     t = SCSI target number.
- *
- * Returns:
- *     NULL = failure
- *
- * Context:
- *     Kernel context.
- */
-static os_tgt_t *
-qla2x00_tgt_alloc(scsi_qla_host_t *ha, uint16_t tgt) 
-{
-       os_tgt_t        *tq;
-
-       /*
-        * If SCSI addressing OK, allocate TGT queue and lock.
-        */
-       if (tgt >= MAX_TARGETS) {
-               DEBUG2(printk("scsi(%ld): Unable to allocate target, invalid "
-                   "target number %d.\n", ha->host_no, tgt));
-               return (NULL);
-       }
-
-       tq = TGT_Q(ha, tgt);
-       if (tq == NULL) {
-               tq = kmalloc(sizeof(os_tgt_t), GFP_ATOMIC);
-               if (tq != NULL) {
-                       DEBUG2(printk("scsi(%ld): Alloc Target %d @ %p\n",
-                           ha->host_no, tgt, tq));
-
-                       memset(tq, 0, sizeof(os_tgt_t));
-                       tq->ha = ha;
-
-                       TGT_Q(ha, tgt) = tq;
-               }
-       }
-       if (tq != NULL) {
-               tq->port_down_retry_count = ha->port_down_retry_count;
-       } else {
-               qla_printk(KERN_WARNING, ha,
-                   "Unable to allocate target.\n");
-               ha->mem_err++;
-       }
-
-       return (tq);
-}
-
-/*
- * qla2x00_tgt_free
- *     Frees target and LUN queues.
- *
- * Input:
- *     ha = adapter block pointer.
- *     t = SCSI target number.
- *
- * Context:
- *     Kernel context.
- */
-void
-qla2x00_tgt_free(scsi_qla_host_t *ha, uint16_t tgt) 
-{
-       os_tgt_t        *tq;
-       uint16_t        lun;
-
-       /*
-        * If SCSI addressing OK, allocate TGT queue and lock.
-        */
-       if (tgt >= MAX_TARGETS) {
-               DEBUG2(printk("scsi(%ld): Unable to de-allocate target, "
-                   "invalid target number %d.\n", ha->host_no, tgt));
-
-               return;
-       }
-
-       tq = TGT_Q(ha, tgt);
-       if (tq != NULL) {
-               TGT_Q(ha, tgt) = NULL;
-
-               /* Free LUN structures. */
-               for (lun = 0; lun < MAX_LUNS; lun++)
-                       qla2x00_lun_free(ha, tgt, lun);
-
-               kfree(tq);
-       }
-
-       return;
-}
-
-/*
- * qla2x00_lun_alloc
- *     Allocate and initialize LUN queue.
- *
- * Input:
- *     ha = adapter block pointer.
- *     t = SCSI target number.
- *     l = LUN number.
- *
- * Returns:
- *     NULL = failure
- *
- * Context:
- *     Kernel context.
- */
-static os_lun_t *
-qla2x00_lun_alloc(scsi_qla_host_t *ha, uint16_t tgt, uint16_t lun) 
-{
-       os_lun_t        *lq;
-
-       /*
-        * If SCSI addressing OK, allocate LUN queue.
-        */
-       if (tgt >= MAX_TARGETS || lun >= MAX_LUNS || TGT_Q(ha, tgt) == NULL) {
-               DEBUG2(printk("scsi(%ld): Unable to allocate lun, invalid "
-                   "parameter.\n", ha->host_no));
-
-               return (NULL);
-       }
-
-       lq = LUN_Q(ha, tgt, lun);
-       if (lq == NULL) {
-               lq = kmalloc(sizeof(os_lun_t), GFP_ATOMIC);
-               if (lq != NULL) {
-                       DEBUG2(printk("scsi(%ld): Alloc Lun %d @ tgt %d.\n",
-                           ha->host_no, lun, tgt));
-
-                       memset(lq, 0, sizeof(os_lun_t));
-                       LUN_Q(ha, tgt, lun) = lq;
-
-                       /*
-                        * The following lun queue initialization code
-                        * must be duplicated in alloc_ioctl_mem function
-                        * for ioctl_lq.
-                        */
-                       lq->q_state = LUN_STATE_READY;
-                       spin_lock_init(&lq->q_lock);
-               }
-       }
-
-       if (lq == NULL) {
-               qla_printk(KERN_WARNING, ha, "Unable to allocate lun.\n");
-       }
-
-       return (lq);
-}
-
-/*
- * qla2x00_lun_free
- *     Frees LUN queue.
- *
- * Input:
- *     ha = adapter block pointer.
- *     t = SCSI target number.
- *
- * Context:
- *     Kernel context.
- */
-static void
-qla2x00_lun_free(scsi_qla_host_t *ha, uint16_t tgt, uint16_t lun) 
-{
-       os_lun_t        *lq;
-
-       /*
-        * If SCSI addressing OK, allocate TGT queue and lock.
-        */
-       if (tgt >= MAX_TARGETS || lun >= MAX_LUNS) {
-               DEBUG2(printk("scsi(%ld): Unable to deallocate lun, invalid "
-                   "parameter.\n", ha->host_no));
-
-               return;
-       }
-
-       if (TGT_Q(ha, tgt) != NULL && (lq = LUN_Q(ha, tgt, lun)) != NULL) {
-               LUN_Q(ha, tgt, lun) = NULL;
-               kfree(lq);
-       }
-
-       return;
 }
 
 /*
                                ha->outstanding_cmds[cnt] = NULL;
                                if (ha->actthreads)
                                        ha->actthreads--;
-                               sp->lun_queue->out_cnt--;
-
                                sp->flags = 0;
                                sp->cmd->result = DID_RESET << 16;
                                sp->cmd->host_scribble = (unsigned char *)NULL;
 
                "Maximum number of mid-layer retries allowed for a command.  "
                "Default value is 20, ");
 
-int displayConfig;
-module_param(displayConfig, int, S_IRUGO|S_IWUSR);
-MODULE_PARM_DESC(displayConfig,
-               "If 1 then display the configuration used in /etc/modprobe.conf.");
-
 int ql2xplogiabsentdevice;
 module_param(ql2xplogiabsentdevice, int, S_IRUGO|S_IWUSR);
 MODULE_PARM_DESC(ql2xplogiabsentdevice,
                "target returns a <NOT READY> status.  Default is 10 "
                "iterations.");
 
-int ql2xdoinitscan = 1;
-module_param(ql2xdoinitscan, int, S_IRUGO|S_IWUSR);
-MODULE_PARM_DESC(ql2xdoinitscan,
-               "Signal mid-layer to perform scan after driver load: 0 -- no "
-               "signal sent to mid-layer.");
-
 int ql2xloginretrycount = 0;
 module_param(ql2xloginretrycount, int, S_IRUGO|S_IRUSR);
 MODULE_PARM_DESC(ql2xloginretrycount,
 
 static struct scsi_transport_template *qla2xxx_transport_template = NULL;
 
-static void qla2x00_display_fc_names(scsi_qla_host_t *);
-
 /* TODO Convert to inlines
  *
  * Timer routines
 qla2x00_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
 {
        scsi_qla_host_t *ha = to_qla_host(cmd->device->host);
-       os_tgt_t *tq = (os_tgt_t *) cmd->device->hostdata;
-       fc_port_t *fcport = tq->fcport;
-       os_lun_t *lq;
+       fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;
        srb_t *sp;
        int rval;
 
-       lq = GET_LU_Q(ha, cmd->device->id, cmd->device->lun);
-       if (!fcport || !lq) {
+       if (!fcport) {
                cmd->result = DID_NO_CONNECT << 16;
                goto qc_fail_command;
        }
        }
 
        sp->ha = ha;
+       sp->fcport = fcport;
        sp->cmd = cmd;
-       sp->tgt_queue = tq;
-
-       sp->lun_queue = lq;
-       lq->io_cnt++;
-       sp->fclun = lq->fclun;
-
        sp->flags = 0;
        sp->err_id = 0;
 
 qla2xxx_eh_device_reset(struct scsi_cmnd *cmd)
 {
        scsi_qla_host_t *ha = to_qla_host(cmd->device->host);
-       os_tgt_t *tq = (os_tgt_t *) cmd->device->hostdata;
-       fc_port_t *fcport = tq->fcport;
-       os_lun_t *lq;
+       fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;
        srb_t *sp;
        int ret;
        unsigned int id, lun;
        serial = cmd->serial_number;
 
        sp = (srb_t *) CMD_SP(cmd);
-       lq = GET_LU_Q(ha, id, lun);
-       if (!sp || !fcport || !lq)
+       if (!sp || !fcport)
                return ret;
 
        qla_printk(KERN_INFO, ha,
 qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd)
 {
        scsi_qla_host_t *ha = to_qla_host(cmd->device->host);
-       os_tgt_t *tq = (os_tgt_t *) cmd->device->hostdata;
-       fc_port_t *fcport = tq->fcport;
-       os_lun_t *lq;
+       fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;
        srb_t *sp;
        int ret;
        unsigned int id, lun;
        serial = cmd->serial_number;
 
        sp = (srb_t *) CMD_SP(cmd);
-       lq = GET_LU_Q(ha, id, lun);
-       if (!sp || !fcport || !lq)
+       if (!sp || !fcport)
                return ret;
 
        qla_printk(KERN_INFO, ha,
 qla2xxx_eh_host_reset(struct scsi_cmnd *cmd)
 {
        scsi_qla_host_t *ha = to_qla_host(cmd->device->host);
-       os_tgt_t *tq = (os_tgt_t *) cmd->device->hostdata;
-       fc_port_t *fcport = tq->fcport;
-       os_lun_t *lq;
+       fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;
        srb_t *sp;
        int ret;
        unsigned int id, lun;
        serial = cmd->serial_number;
 
        sp = (srb_t *) CMD_SP(cmd);
-       lq = GET_LU_Q(ha, id, lun);
-       if (!sp || !fcport || !lq)
+       if (!sp || !fcport)
                return ret;
 
        qla_printk(KERN_INFO, ha,
 qla2x00_loop_reset(scsi_qla_host_t *ha)
 {
        int status = QLA_SUCCESS;
-       uint16_t t;
-       os_tgt_t        *tq;
+       struct fc_port *fcport;
 
        if (ha->flags.enable_lip_reset) {
                status = qla2x00_lip_reset(ha);
        }
 
        if (status == QLA_SUCCESS && ha->flags.enable_target_reset) {
-               for (t = 0; t < MAX_FIBRE_DEVICES; t++) {
-                       if ((tq = TGT_Q(ha, t)) == NULL)
-                               continue;
-
-                       if (tq->fcport == NULL)
+               list_for_each_entry(fcport, &ha->fcports, list) {
+                       if (fcport->port_type != FCT_TARGET)
                                continue;
 
-                       status = qla2x00_target_reset(ha, 0, t);
-                       if (status != QLA_SUCCESS) {
+                       status = qla2x00_target_reset(ha, fcport);
+                       if (status != QLA_SUCCESS)
                                break;
-                       }
                }
        }
 
 qla2xxx_slave_alloc(struct scsi_device *sdev)
 {
        scsi_qla_host_t *ha = to_qla_host(sdev->host);
-       os_tgt_t *tq;
+       struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
+       fc_port_t *fcport;
+       int found;
 
-       tq = (os_tgt_t *) TGT_Q(ha, sdev->id);
-       if (!tq)
+       if (!rport)
                return -ENXIO;
-       if (!tq->fcport)
+
+       found = 0;
+       list_for_each_entry(fcport, &ha->fcports, list) {
+               if (rport->port_name ==
+                   be64_to_cpu(*(uint64_t *)fcport->port_name)) {
+                       found++;
+                       break;
+               }
+               
+       }
+       if (!found)
                return -ENXIO;
 
-       sdev->hostdata = tq;
+       sdev->hostdata = fcport;
 
        return 0;
 }
        }
 
        qla2x00_init_host_attr(ha);
+
        /*
         * Startup the kernel thread for this host adapter
         */
        ha->flags.init_done = 1;
        num_hosts++;
 
-       /* List the target we have found */
-       if (displayConfig) {
-               qla2x00_display_fc_names(ha);
-       }
-
        qla_printk(KERN_INFO, ha, "\n"
            " QLogic Fibre Channel HBA Driver: %s\n"
            "  QLogic %s - %s\n"
        return 0;
 
 probe_failed:
+       fc_remove_host(ha->host);
+
        scsi_remove_host(host);
 
 probe_alloc_failed:
 
        qla2x00_free_sysfs_attr(ha);
 
+       fc_remove_host(ha->host);
+
        scsi_remove_host(ha->host);
 
        qla2x00_free_device(ha);
 {
        struct info_str info;
        int             retval = -EINVAL;
-       os_lun_t        *up;
-       os_tgt_t        *tq;
-       unsigned int    t, l;
        uint32_t        tmp_sn;
        uint32_t        *flags;
        uint8_t         *loop_state;
            ha->init_cb->port_name[6],
            ha->init_cb->port_name[7]);
 
-       /* Print out device port names */
-       for (t = 0; t < MAX_FIBRE_DEVICES; t++) {
-               if ((tq = TGT_Q(ha, t)) == NULL)
-                       continue;
-
-               copy_info(&info,
-                   "scsi-qla%d-target-%d="
-                   "%02x%02x%02x%02x%02x%02x%02x%02x;\n",
-                   (int)ha->instance, t,
-                   tq->port_name[0], tq->port_name[1],
-                   tq->port_name[2], tq->port_name[3],
-                   tq->port_name[4], tq->port_name[5],
-                   tq->port_name[6], tq->port_name[7]);
-       }
-
-       copy_info(&info, "\nSCSI LUN Information:\n");
-       copy_info(&info,
-           "(Id:Lun)  * - indicates lun is not registered with the OS.\n");
-
-       /* scan for all equipment stats */
-       for (t = 0; t < MAX_FIBRE_DEVICES; t++) {
-               /* scan all luns */
-               for (l = 0; l < ha->max_luns; l++) {
-                       up = (os_lun_t *) GET_LU_Q(ha, t, l);
-
-                       if (up == NULL) {
-                               continue;
-                       }
-                       if (up->fclun == NULL) {
-                               continue;
-                       }
-
-                       copy_info(&info,
-                           "(%2d:%2d): Total reqs %ld,",
-                           t,l,up->io_cnt);
-
-                       copy_info(&info,
-                           " Pending reqs %ld,",
-                           up->out_cnt);
-
-                       if (up->io_cnt < 4) {
-                               copy_info(&info,
-                                   " flags 0x%x*,",
-                                   (int)up->q_flag);
-                       } else {
-                               copy_info(&info,
-                                   " flags 0x%x,",
-                                   (int)up->q_flag);
-                       }
-
-                       copy_info(&info, 
-                           " %ld:%d:%02x %02x",
-                           up->fclun->fcport->ha->instance,
-                           up->fclun->fcport->cur_path,
-                           up->fclun->fcport->loop_id,
-                           up->fclun->device_type);
-
-                       copy_info(&info, "\n");
-
-                       if (info.pos >= info.offset + info.length) {
-                               /* No need to continue */
-                               goto profile_stop;
-                       }
-               }
-
-               if (info.pos >= info.offset + info.length) {
-                       /* No need to continue */
-                       break;
-               }
-       }
-
-profile_stop:
-
        retval = info.pos > info.offset ? info.pos - info.offset : 0;
 
        DEBUG3(printk(KERN_INFO 
        return (retval);
 }
 
-/*
-* qla2x00_display_fc_names
-*      This routine will the node names of the different devices found
-*      after port inquiry.
-*
-* Input:
-*      cmd = SCSI command structure
-*
-* Returns:
-*      None.
-*/
-static void
-qla2x00_display_fc_names(scsi_qla_host_t *ha) 
-{
-       uint16_t        tgt;
-       os_tgt_t        *tq;
-
-       /* Display the node name for adapter */
-       qla_printk(KERN_INFO, ha,
-           "scsi-qla%d-adapter-node=%02x%02x%02x%02x%02x%02x%02x%02x\\;\n",
-           (int)ha->instance,
-           ha->init_cb->node_name[0],
-           ha->init_cb->node_name[1],
-           ha->init_cb->node_name[2],
-           ha->init_cb->node_name[3],
-           ha->init_cb->node_name[4],
-           ha->init_cb->node_name[5],
-           ha->init_cb->node_name[6],
-           ha->init_cb->node_name[7]);
-
-       /* display the port name for adapter */
-       qla_printk(KERN_INFO, ha,
-           "scsi-qla%d-adapter-port=%02x%02x%02x%02x%02x%02x%02x%02x\\;\n",
-           (int)ha->instance,
-           ha->init_cb->port_name[0],
-           ha->init_cb->port_name[1],
-           ha->init_cb->port_name[2],
-           ha->init_cb->port_name[3],
-           ha->init_cb->port_name[4],
-           ha->init_cb->port_name[5],
-           ha->init_cb->port_name[6],
-           ha->init_cb->port_name[7]);
-
-       /* Print out device port names */
-       for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
-               if ((tq = ha->otgt[tgt]) == NULL)
-                       continue;
-
-               if (tq->fcport == NULL)
-                       continue;
-
-               switch (ha->binding_type) {
-                       case BIND_BY_PORT_NAME:
-                               qla_printk(KERN_INFO, ha,
-                                   "scsi-qla%d-tgt-%d-di-0-port="
-                                   "%02x%02x%02x%02x%02x%02x%02x%02x\\;\n",
-                                   (int)ha->instance, 
-                                   tgt,
-                                   tq->port_name[0], 
-                                   tq->port_name[1],
-                                   tq->port_name[2], 
-                                   tq->port_name[3],
-                                   tq->port_name[4], 
-                                   tq->port_name[5],
-                                   tq->port_name[6], 
-                                   tq->port_name[7]);
-
-                               break;
-
-                       case BIND_BY_PORT_ID:
-                               qla_printk(KERN_INFO, ha,
-                                   "scsi-qla%d-tgt-%d-di-0-pid="
-                                   "%02x%02x%02x\\;\n",
-                                   (int)ha->instance,
-                                   tgt,
-                                   tq->d_id.b.domain,
-                                   tq->d_id.b.area,
-                                   tq->d_id.b.al_pa);
-                               break;
-               }
-
-#if VSA
-               qla_printk(KERN_INFO, ha,
-                   "scsi-qla%d-target-%d-vsa=01;\n", (int)ha->instance, tgt);
-#endif
-       }
-}
-
-
 /*
  * qla2x00_mark_device_lost Updates fcport state when device goes offline.
  *
 static void
 qla2x00_mem_free(scsi_qla_host_t *ha)
 {
-       uint32_t        t;
        struct list_head        *fcpl, *fcptemp;
        fc_port_t       *fcport;
-       struct list_head        *fcll, *fcltemp;
-       fc_lun_t        *fclun;
        unsigned long   wtime;/* max wait time if mbx cmd is busy. */
 
        if (ha == NULL) {
                return;
        }
 
-       /* Free the target queues */
-       for (t = 0; t < MAX_TARGETS; t++) {
-               qla2x00_tgt_free(ha, t);
-       }
-
        /* Make sure all other threads are stopped. */
        wtime = 60 * HZ;
        while (ha->dpc_wait && wtime) {
        list_for_each_safe(fcpl, fcptemp, &ha->fcports) {
                fcport = list_entry(fcpl, fc_port_t, list);
 
-               /* fc luns */
-               list_for_each_safe(fcll, fcltemp, &fcport->fcluns) {
-                       fclun = list_entry(fcll, fc_lun_t, list);
-
-                       list_del_init(&fclun->list);
-                       kfree(fclun);
-               }
-
                /* fc ports */
                list_del_init(&fcport->list);
                kfree(fcport);
 
        cmd->scsi_done(cmd);
 }
+
 /**************************************************************************
 *   qla2x00_timer
 *
                        spin_lock_irqsave(&ha->hardware_lock, cpu_flags);
                        for (index = 1; index < MAX_OUTSTANDING_COMMANDS;
                            index++) {
+                               fc_port_t *sfcp;
+
                                sp = ha->outstanding_cmds[index];
                                if (!sp)
                                        continue;
-                               if (!(sp->fclun->fcport->flags &
-                                   FCF_TAPE_PRESENT))
+                               sfcp = sp->fcport;
+                               if (!(sfcp->flags & FCF_TAPE_PRESENT))
                                        continue;
 
                                set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);