scsi: qla2xxx: Enable type checking for the SRB free and done callback functions
[linux-2.6-block.git] / drivers / scsi / qla2xxx / qla_bsg.c
index 5441557b424b3c0861473ce3574a38135783cdef..28d587a89ba61efcab7a497e8c9319a7b9272359 100644 (file)
 #include <linux/bsg-lib.h>
 
 /* BSG support for ELS/CT pass through */
-void
-qla2x00_bsg_job_done(void *ptr, int res)
+void qla2x00_bsg_job_done(srb_t *sp, int res)
 {
-       srb_t *sp = ptr;
        struct bsg_job *bsg_job = sp->u.bsg_job;
        struct fc_bsg_reply *bsg_reply = bsg_job->reply;
 
@@ -25,10 +23,8 @@ qla2x00_bsg_job_done(void *ptr, int res)
        sp->free(sp);
 }
 
-void
-qla2x00_bsg_sp_free(void *ptr)
+void qla2x00_bsg_sp_free(srb_t *sp)
 {
-       srb_t *sp = ptr;
        struct qla_hw_data *ha = sp->vha->hw;
        struct bsg_job *bsg_job = sp->u.bsg_job;
        struct fc_bsg_request *bsg_request = bsg_job->request;
@@ -341,6 +337,8 @@ qla2x00_process_els(struct bsg_job *bsg_job)
                dma_map_sg(&ha->pdev->dev, bsg_job->request_payload.sg_list,
                bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE);
        if (!req_sg_cnt) {
+               dma_unmap_sg(&ha->pdev->dev, bsg_job->request_payload.sg_list,
+                   bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE);
                rval = -ENOMEM;
                goto done_free_fcport;
        }
@@ -348,6 +346,8 @@ qla2x00_process_els(struct bsg_job *bsg_job)
        rsp_sg_cnt = dma_map_sg(&ha->pdev->dev, bsg_job->reply_payload.sg_list,
                bsg_job->reply_payload.sg_cnt, DMA_FROM_DEVICE);
         if (!rsp_sg_cnt) {
+               dma_unmap_sg(&ha->pdev->dev, bsg_job->reply_payload.sg_list,
+                   bsg_job->reply_payload.sg_cnt, DMA_FROM_DEVICE);
                rval = -ENOMEM;
                goto done_free_fcport;
        }
@@ -1778,8 +1778,8 @@ qla24xx_process_bidir_cmd(struct bsg_job *bsg_job)
        uint16_t nextlid = 0;
        uint32_t tot_dsds;
        srb_t *sp = NULL;
-       uint32_t req_data_len = 0;
-       uint32_t rsp_data_len = 0;
+       uint32_t req_data_len;
+       uint32_t rsp_data_len;
 
        /* Check the type of the adapter */
        if (!IS_BIDI_CAPABLE(ha)) {
@@ -1884,6 +1884,9 @@ qla24xx_process_bidir_cmd(struct bsg_job *bsg_job)
                goto done_unmap_sg;
        }
 
+       req_data_len = bsg_job->request_payload.payload_len;
+       rsp_data_len = bsg_job->reply_payload.payload_len;
+
        if (req_data_len != rsp_data_len) {
                rval = EXT_STATUS_BUSY;
                ql_log(ql_log_warn, vha, 0x70aa,
@@ -1891,10 +1894,6 @@ qla24xx_process_bidir_cmd(struct bsg_job *bsg_job)
                goto done_unmap_sg;
        }
 
-       req_data_len = bsg_job->request_payload.payload_len;
-       rsp_data_len = bsg_job->reply_payload.payload_len;
-
-
        /* Alloc SRB structure */
        sp = qla2x00_get_sp(vha, &(vha->bidir_fcport), GFP_KERNEL);
        if (!sp) {