Merge branch 'stable-3.2' into pandora-3.2
[pandora-kernel.git] / drivers / scsi / qla2xxx / qla_bsg.c
index 8b641a8..30edc4b 100644 (file)
@@ -1400,9 +1400,12 @@ qla2x00_read_optrom(struct fc_bsg_job *bsg_job)
        struct qla_hw_data *ha = vha->hw;
        int rval = 0;
 
+       mutex_lock(&ha->optrom_mutex);
        rval = qla2x00_optrom_setup(bsg_job, vha, 0);
-       if (rval)
+       if (rval) {
+               mutex_unlock(&ha->optrom_mutex);
                return rval;
+       }
 
        ha->isp_ops->read_optrom(vha, ha->optrom_buffer,
            ha->optrom_region_start, ha->optrom_region_size);
@@ -1416,6 +1419,7 @@ qla2x00_read_optrom(struct fc_bsg_job *bsg_job)
        vfree(ha->optrom_buffer);
        ha->optrom_buffer = NULL;
        ha->optrom_state = QLA_SWAITING;
+       mutex_unlock(&ha->optrom_mutex);
        bsg_job->job_done(bsg_job);
        return rval;
 }
@@ -1428,9 +1432,12 @@ qla2x00_update_optrom(struct fc_bsg_job *bsg_job)
        struct qla_hw_data *ha = vha->hw;
        int rval = 0;
 
+       mutex_lock(&ha->optrom_mutex);
        rval = qla2x00_optrom_setup(bsg_job, vha, 1);
-       if (rval)
+       if (rval) {
+               mutex_unlock(&ha->optrom_mutex);
                return rval;
+       }
 
        sg_copy_to_buffer(bsg_job->request_payload.sg_list,
            bsg_job->request_payload.sg_cnt, ha->optrom_buffer,
@@ -1443,6 +1450,7 @@ qla2x00_update_optrom(struct fc_bsg_job *bsg_job)
        vfree(ha->optrom_buffer);
        ha->optrom_buffer = NULL;
        ha->optrom_state = QLA_SWAITING;
+       mutex_unlock(&ha->optrom_mutex);
        bsg_job->job_done(bsg_job);
        return rval;
 }