scsi: qla2xxx: Enable type checking for the SRB free and done callback functions
[linux-2.6-block.git] / drivers / scsi / qla2xxx / qla_iocb.c
index 9312b19ed708b6687db85d8b41fa721f159da324..59a0a778d31c83aaad1a54e6366ab5c70d19264a 100644 (file)
@@ -1364,6 +1364,7 @@ qla24xx_walk_and_build_prot_sglist(struct qla_hw_data *ha, srb_t *sp,
        cur_dsd++;
        return 0;
 }
+
 /**
  * qla24xx_build_scsi_crc_2_iocbs() - Build IOCB command utilizing Command
  *                                                     Type 6 IOCB types.
@@ -1515,7 +1516,7 @@ qla24xx_build_scsi_crc_2_iocbs(srb_t *sp, struct cmd_type_crc_2 *cmd_pkt,
        }
 
        if (!bundling) {
-               cur_dsd = &crc_ctx_pkt->u.nobundling.data_dsd;
+               cur_dsd = &crc_ctx_pkt->u.nobundling.data_dsd[0];
        } else {
                /*
                 * Configure Bundling if we need to fetch interlaving
@@ -1525,7 +1526,7 @@ qla24xx_build_scsi_crc_2_iocbs(srb_t *sp, struct cmd_type_crc_2 *cmd_pkt,
                crc_ctx_pkt->u.bundling.dif_byte_count = cpu_to_le32(dif_bytes);
                crc_ctx_pkt->u.bundling.dseg_count = cpu_to_le16(tot_dsds -
                                                        tot_prot_dsds);
-               cur_dsd = &crc_ctx_pkt->u.bundling.data_dsd;
+               cur_dsd = &crc_ctx_pkt->u.bundling.data_dsd[0];
        }
 
        /* Finish the common fields of CRC pkt */
@@ -2540,13 +2541,11 @@ void qla2x00_init_timer(srb_t *sp, unsigned long tmo)
        sp->free = qla2x00_sp_free;
        if (IS_QLAFX00(sp->vha->hw) && sp->type == SRB_FXIOCB_DCMD)
                init_completion(&sp->u.iocb_cmd.u.fxiocb.fxiocb_comp);
-       add_timer(&sp->u.iocb_cmd.timer);
+       sp->start_timer = 1;
 }
 
-static void
-qla2x00_els_dcmd_sp_free(void *data)
+static void qla2x00_els_dcmd_sp_free(srb_t *sp)
 {
-       srb_t *sp = data;
        struct srb_iocb *elsio = &sp->u.iocb_cmd;
 
        kfree(sp->fcport);
@@ -2576,10 +2575,8 @@ qla2x00_els_dcmd_iocb_timeout(void *data)
        complete(&lio->u.els_logo.comp);
 }
 
-static void
-qla2x00_els_dcmd_sp_done(void *ptr, int res)
+static void qla2x00_els_dcmd_sp_done(srb_t *sp, int res)
 {
-       srb_t *sp = ptr;
        fc_port_t *fcport = sp->fcport;
        struct srb_iocb *lio = &sp->u.iocb_cmd;
        struct scsi_qla_host *vha = sp->vha;
@@ -2699,16 +2696,16 @@ qla24xx_els_logo_iocb(srb_t *sp, struct els_entry_24xx *els_iocb)
        els_iocb->s_id[0] = vha->d_id.b.al_pa;
        els_iocb->s_id[1] = vha->d_id.b.area;
        els_iocb->s_id[2] = vha->d_id.b.domain;
-       els_iocb->control_flags = 0;
 
        if (elsio->u.els_logo.els_cmd == ELS_DCMD_PLOGI) {
+               els_iocb->control_flags = 0;
                els_iocb->tx_byte_count = els_iocb->tx_len =
-                       sizeof(struct els_plogi_payload);
+                       cpu_to_le32(sizeof(struct els_plogi_payload));
                put_unaligned_le64(elsio->u.els_plogi.els_plogi_pyld_dma,
                                   &els_iocb->tx_address);
                els_iocb->rx_dsd_count = 1;
                els_iocb->rx_byte_count = els_iocb->rx_len =
-                       sizeof(struct els_plogi_payload);
+                       cpu_to_le32(sizeof(struct els_plogi_payload));
                put_unaligned_le64(elsio->u.els_plogi.els_resp_pyld_dma,
                                   &els_iocb->rx_address);
 
@@ -2717,7 +2714,9 @@ qla24xx_els_logo_iocb(srb_t *sp, struct els_entry_24xx *els_iocb)
                ql_dump_buffer(ql_log_info, vha, 0x0109,
                    (uint8_t *)els_iocb, 0x70);
        } else {
-               els_iocb->tx_byte_count = sizeof(struct els_logo_payload);
+               els_iocb->control_flags = 1 << 13;
+               els_iocb->tx_byte_count =
+                       cpu_to_le32(sizeof(struct els_logo_payload));
                put_unaligned_le64(elsio->u.els_logo.els_logo_pyld_dma,
                                   &els_iocb->tx_address);
                els_iocb->tx_len = cpu_to_le32(sizeof(struct els_logo_payload));
@@ -2755,10 +2754,8 @@ qla2x00_els_dcmd2_iocb_timeout(void *data)
        sp->done(sp, QLA_FUNCTION_TIMEOUT);
 }
 
-static void
-qla2x00_els_dcmd2_sp_done(void *ptr, int res)
+static void qla2x00_els_dcmd2_sp_done(srb_t *sp, int res)
 {
-       srb_t *sp = ptr;
        fc_port_t *fcport = sp->fcport;
        struct srb_iocb *lio = &sp->u.iocb_cmd;
        struct scsi_qla_host *vha = sp->vha;
@@ -3668,6 +3665,9 @@ qla2x00_start_sp(srb_t *sp)
                break;
        }
 
+       if (sp->start_timer)
+               add_timer(&sp->u.iocb_cmd.timer);
+
        wmb();
        qla2x00_start_iocbs(vha, qp->req);
 done: