Skip to content

Commit

Permalink
scsi: fc: Export fc_bsg_jobdone and use it in FC drivers
Browse files Browse the repository at this point in the history
Export fc_bsg_jobdone so drivers can use it directly instead of doing
the round-trip via struct fc_bsg_job::job_done() and use it in the
LLDDs.  That way we can also unify the interfaces of fc_bsg_jobdone and
bsg_job_done.

As we've converted all LLDDs over to use fc_bsg_jobdone() directly, we
can remove the function pointer from struct fc_bsg_job as well.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Acked-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
  • Loading branch information
Johannes Thumshirn authored and Martin K. Petersen committed Nov 18, 2016
1 parent 01e0e15 commit 1abaede
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 63 deletions.
2 changes: 1 addition & 1 deletion drivers/s390/scsi/zfcp_fc.c
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ static void zfcp_fc_ct_els_job_handler(void *data)
jr->reply_payload_rcv_len = job->reply_payload.payload_len;
jr->reply_data.ctels_reply.status = FC_CTELS_STATUS_OK;
jr->result = zfcp_ct_els->status ? -EIO : 0;
job->job_done(job);
fc_bsg_jobdone(job, jr->result, jr->reply_payload_rcv_len);
}

static struct zfcp_fc_wka_port *zfcp_fc_job_wka_port(struct fc_bsg_job *job)
Expand Down
6 changes: 4 additions & 2 deletions drivers/scsi/bfa/bfad_bsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -3180,7 +3180,8 @@ bfad_im_bsg_vendor_request(struct fc_bsg_job *job)
bsg_reply->reply_payload_rcv_len = job->reply_payload.payload_len;
bsg_reply->result = rc;

job->job_done(job);
fc_bsg_jobdone(job, bsg_reply->result,
bsg_reply->reply_payload_rcv_len);
return rc;
error:
/* free the command buffer */
Expand Down Expand Up @@ -3556,7 +3557,8 @@ bfad_im_bsg_els_ct_request(struct fc_bsg_job *job)
bsg_reply->result = rc;

if (rc == BFA_STATUS_OK)
job->job_done(job);
fc_bsg_jobdone(job, bsg_reply->result,
bsg_reply->reply_payload_rcv_len);

return rc;
}
Expand Down
3 changes: 2 additions & 1 deletion drivers/scsi/ibmvscsi/ibmvfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1945,7 +1945,8 @@ static int ibmvfc_bsg_request(struct fc_bsg_job *job)
ibmvfc_free_event(evt);
spin_unlock_irqrestore(vhost->host->host_lock, flags);
bsg_reply->result = rc;
job->job_done(job);
fc_bsg_jobdone(job, bsg_reply->result,
bsg_reply->reply_payload_rcv_len);
rc = 0;
out:
dma_unmap_sg(vhost->dev, job->request_payload.sg_list,
Expand Down
6 changes: 4 additions & 2 deletions drivers/scsi/libfc/fc_lport.c
Original file line number Diff line number Diff line change
Expand Up @@ -1913,7 +1913,8 @@ static void fc_lport_bsg_resp(struct fc_seq *sp, struct fc_frame *fp,
-ECONNABORTED : -ETIMEDOUT;
job->reply_len = sizeof(uint32_t);
job->state_flags |= FC_RQST_STATE_DONE;
job->job_done(job);
fc_bsg_jobdone(job, bsg_reply->result,
bsg_reply->reply_payload_rcv_len);
kfree(info);
return;
}
Expand Down Expand Up @@ -1948,7 +1949,8 @@ static void fc_lport_bsg_resp(struct fc_seq *sp, struct fc_frame *fp,
job->reply_payload.payload_len;
bsg_reply->result = 0;
job->state_flags |= FC_RQST_STATE_DONE;
job->job_done(job);
fc_bsg_jobdone(job, bsg_reply->result,
bsg_reply->reply_payload_rcv_len);
kfree(info);
}
fc_frame_free(fp);
Expand Down
71 changes: 48 additions & 23 deletions drivers/scsi/lpfc/lpfc_bsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,8 @@ lpfc_bsg_send_mgmt_cmd_cmp(struct lpfc_hba *phba,

if (job) {
bsg_reply->result = rc;
job->job_done(job);
fc_bsg_jobdone(job, bsg_reply->result,
bsg_reply->reply_payload_rcv_len);
}
return;
}
Expand Down Expand Up @@ -644,7 +645,8 @@ lpfc_bsg_rport_els_cmp(struct lpfc_hba *phba,

if (job) {
bsg_reply->result = rc;
job->job_done(job);
fc_bsg_jobdone(job, bsg_reply->result,
bsg_reply->reply_payload_rcv_len);
}
return;
}
Expand Down Expand Up @@ -1136,7 +1138,8 @@ lpfc_bsg_ct_unsol_event(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
job->dd_data = NULL;
/* complete the job back to userspace */
spin_unlock_irqrestore(&phba->ct_ev_lock, flags);
job->job_done(job);
fc_bsg_jobdone(job, bsg_reply->result,
bsg_reply->reply_payload_rcv_len);
spin_lock_irqsave(&phba->ct_ev_lock, flags);
}
}
Expand Down Expand Up @@ -1361,7 +1364,8 @@ lpfc_bsg_hba_get_event(struct fc_bsg_job *job)
spin_unlock_irqrestore(&phba->ct_ev_lock, flags);
job->dd_data = NULL;
bsg_reply->result = 0;
job->job_done(job);
fc_bsg_jobdone(job, bsg_reply->result,
bsg_reply->reply_payload_rcv_len);
return 0;

job_error:
Expand Down Expand Up @@ -1458,7 +1462,8 @@ lpfc_issue_ct_rsp_cmp(struct lpfc_hba *phba,

if (job) {
bsg_reply->result = rc;
job->job_done(job);
fc_bsg_jobdone(job, bsg_reply->result,
bsg_reply->reply_payload_rcv_len);
}
return;
}
Expand Down Expand Up @@ -1886,7 +1891,8 @@ lpfc_sli3_bsg_diag_loopback_mode(struct lpfc_hba *phba, struct fc_bsg_job *job)
bsg_reply->result = rc;
/* complete the job back to userspace if no error */
if (rc == 0)
job->job_done(job);
fc_bsg_jobdone(job, bsg_reply->result,
bsg_reply->reply_payload_rcv_len);
return rc;
}

Expand Down Expand Up @@ -2175,7 +2181,8 @@ lpfc_sli4_bsg_diag_loopback_mode(struct lpfc_hba *phba, struct fc_bsg_job *job)
bsg_reply->result = rc;
/* complete the job back to userspace if no error */
if (rc == 0)
job->job_done(job);
fc_bsg_jobdone(job, bsg_reply->result,
bsg_reply->reply_payload_rcv_len);
return rc;
}

Expand Down Expand Up @@ -2289,7 +2296,8 @@ lpfc_sli4_bsg_diag_mode_end(struct fc_bsg_job *job)
bsg_reply->result = rc;
/* complete the job back to userspace if no error */
if (rc == 0)
job->job_done(job);
fc_bsg_jobdone(job, bsg_reply->result,
bsg_reply->reply_payload_rcv_len);
return rc;
}

Expand Down Expand Up @@ -2441,7 +2449,8 @@ lpfc_sli4_bsg_link_diag_test(struct fc_bsg_job *job)
bsg_reply->result = rc;
/* complete the job back to userspace if no error */
if (rc == 0)
job->job_done(job);
fc_bsg_jobdone(job, bsg_reply->result,
bsg_reply->reply_payload_rcv_len);
return rc;
}

Expand Down Expand Up @@ -3301,7 +3310,8 @@ lpfc_bsg_diag_loopback_run(struct fc_bsg_job *job)
job->dd_data = NULL;
/* complete the job back to userspace if no error */
if (rc == IOCB_SUCCESS)
job->job_done(job);
fc_bsg_jobdone(job, bsg_reply->result,
bsg_reply->reply_payload_rcv_len);
return rc;
}

Expand Down Expand Up @@ -3344,7 +3354,8 @@ lpfc_bsg_get_dfc_rev(struct fc_bsg_job *job)
job_error:
bsg_reply->result = rc;
if (rc == 0)
job->job_done(job);
fc_bsg_jobdone(job, bsg_reply->result,
bsg_reply->reply_payload_rcv_len);
return rc;
}

Expand Down Expand Up @@ -3409,7 +3420,8 @@ lpfc_bsg_issue_mbox_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq)

if (job) {
bsg_reply->result = 0;
job->job_done(job);
fc_bsg_jobdone(job, bsg_reply->result,
bsg_reply->reply_payload_rcv_len);
}
return;
}
Expand Down Expand Up @@ -3635,6 +3647,7 @@ static void
lpfc_bsg_issue_read_mbox_ext_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq)
{
struct fc_bsg_job *job;
struct fc_bsg_reply *bsg_reply;

job = lpfc_bsg_issue_mbox_ext_handle_job(phba, pmboxq);

Expand All @@ -3654,9 +3667,11 @@ lpfc_bsg_issue_read_mbox_ext_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq)
mempool_free(pmboxq, phba->mbox_mem_pool);

/* if the job is still active, call job done */
if (job)
job->job_done(job);

if (job) {
bsg_reply = job->reply;
fc_bsg_jobdone(job, bsg_reply->result,
bsg_reply->reply_payload_rcv_len);
}
return;
}

Expand All @@ -3672,6 +3687,7 @@ static void
lpfc_bsg_issue_write_mbox_ext_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq)
{
struct fc_bsg_job *job;
struct fc_bsg_reply *bsg_reply;

job = lpfc_bsg_issue_mbox_ext_handle_job(phba, pmboxq);

Expand All @@ -3689,8 +3705,11 @@ lpfc_bsg_issue_write_mbox_ext_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmboxq)
lpfc_bsg_mbox_ext_session_reset(phba);

/* if the job is still active, call job done */
if (job)
job->job_done(job);
if (job) {
bsg_reply = job->reply;
fc_bsg_jobdone(job, bsg_reply->result,
bsg_reply->reply_payload_rcv_len);
}

return;
}
Expand Down Expand Up @@ -4131,7 +4150,8 @@ lpfc_bsg_sli_cfg_write_cmd_ext(struct lpfc_hba *phba, struct fc_bsg_job *job,
/* wait for additoinal external buffers */

bsg_reply->result = 0;
job->job_done(job);
fc_bsg_jobdone(job, bsg_reply->result,
bsg_reply->reply_payload_rcv_len);
return SLI_CONFIG_HANDLED;

job_error:
Expand Down Expand Up @@ -4357,7 +4377,8 @@ lpfc_bsg_read_ebuf_get(struct lpfc_hba *phba, struct fc_bsg_job *job)
}

bsg_reply->result = 0;
job->job_done(job);
fc_bsg_jobdone(job, bsg_reply->result,
bsg_reply->reply_payload_rcv_len);

return SLI_CONFIG_HANDLED;
}
Expand Down Expand Up @@ -4473,7 +4494,8 @@ lpfc_bsg_write_ebuf_set(struct lpfc_hba *phba, struct fc_bsg_job *job,

/* wait for additoinal external buffers */
bsg_reply->result = 0;
job->job_done(job);
fc_bsg_jobdone(job, bsg_reply->result,
bsg_reply->reply_payload_rcv_len);
return SLI_CONFIG_HANDLED;

job_error:
Expand Down Expand Up @@ -4941,7 +4963,8 @@ lpfc_bsg_mbox_cmd(struct fc_bsg_job *job)
/* job done */
bsg_reply->result = 0;
job->dd_data = NULL;
job->job_done(job);
fc_bsg_jobdone(job, bsg_reply->result,
bsg_reply->reply_payload_rcv_len);
} else if (rc == 1)
/* job submitted, will complete later*/
rc = 0; /* return zero, no error */
Expand Down Expand Up @@ -5051,7 +5074,8 @@ lpfc_bsg_menlo_cmd_cmp(struct lpfc_hba *phba,

if (job) {
bsg_reply->result = rc;
job->job_done(job);
fc_bsg_jobdone(job, bsg_reply->result,
bsg_reply->reply_payload_rcv_len);
}

return;
Expand Down Expand Up @@ -5269,7 +5293,8 @@ lpfc_forced_link_speed(struct fc_bsg_job *job)
job_error:
bsg_reply->result = rc;
if (rc == 0)
job->job_done(job);
fc_bsg_jobdone(job, bsg_reply->result,
bsg_reply->reply_payload_rcv_len);
return rc;
}

Expand Down
Loading

0 comments on commit 1abaede

Please sign in to comment.