Skip to content

Commit

Permalink
scsi: qla2xxx: Enable type checking for the SRB free and done callbac…
Browse files Browse the repository at this point in the history
…k functions

Since all pointers passed to the srb_t.done() and srb_t.free() functions
have type srb_t, change the type of the first argument of these functions
from void * into struct srb *. This allows the compiler to verify the
argument types for these functions. This patch does not change any
functionality.

Cc: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Tested-by: Himanshu Madhani <hmadhani@marvell.com>
Reviewed-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
  • Loading branch information
Bart Van Assche authored and Martin K. Petersen committed Aug 13, 2019
1 parent aa20e38 commit 6c18a43
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 100 deletions.
8 changes: 2 additions & 6 deletions drivers/scsi/qla2xxx/qla_bsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@
#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;

Expand All @@ -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;
Expand Down
14 changes: 12 additions & 2 deletions drivers/scsi/qla2xxx/qla_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -614,8 +614,18 @@ typedef struct srb {
struct bsg_job *bsg_job;
struct srb_cmd scmd;
} u;
void (*done)(void *, int);
void (*free)(void *);
/*
* Report completion status @res and call sp_put(@sp). @res is
* an NVMe status code, a SCSI result (e.g. DID_OK << 16) or a
* QLA_* status value.
*/
void (*done)(struct srb *sp, int res);
/* Stop the timer and free @sp. Only used by the FCP code. */
void (*free)(struct srb *sp);
/*
* Call nvme_private->fd->done() and free @sp. Only used by the NVMe
* code.
*/
void (*put_fn)(struct kref *kref);
} srb_t;

Expand Down
14 changes: 7 additions & 7 deletions drivers/scsi/qla2xxx/qla_gbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,9 @@ extern int qla2x00_post_uevent_work(struct scsi_qla_host *, u32);

extern int qla2x00_post_uevent_work(struct scsi_qla_host *, u32);
extern void qla2x00_disable_board_on_pci_error(struct work_struct *);
extern void qla2x00_sp_compl(void *, int);
extern void qla2xxx_qpair_sp_free_dma(void *);
extern void qla2xxx_qpair_sp_compl(void *, int);
extern void qla2x00_sp_compl(srb_t *sp, int);
extern void qla2xxx_qpair_sp_free_dma(srb_t *sp);
extern void qla2xxx_qpair_sp_compl(srb_t *sp, int);
extern void qla24xx_sched_upd_fcport(fc_port_t *);
void qla2x00_handle_login_done_event(struct scsi_qla_host *, fc_port_t *,
uint16_t *);
Expand Down Expand Up @@ -244,7 +244,7 @@ extern void qla2x00_do_dpc_all_vps(scsi_qla_host_t *);
extern int qla24xx_vport_create_req_sanity_check(struct fc_vport *);
extern scsi_qla_host_t *qla24xx_create_vhost(struct fc_vport *);

extern void qla2x00_sp_free_dma(void *);
extern void qla2x00_sp_free_dma(srb_t *sp);
extern char *qla2x00_get_fw_version_str(struct scsi_qla_host *, char *);

extern void qla2x00_mark_device_lost(scsi_qla_host_t *, fc_port_t *, int, int);
Expand Down Expand Up @@ -790,10 +790,10 @@ extern int qla82xx_restart_isp(scsi_qla_host_t *);

/* IOCB related functions */
extern int qla82xx_start_scsi(srb_t *);
extern void qla2x00_sp_free(void *);
extern void qla2x00_sp_free(srb_t *sp);
extern void qla2x00_sp_timeout(struct timer_list *);
extern void qla2x00_bsg_job_done(void *, int);
extern void qla2x00_bsg_sp_free(void *);
extern void qla2x00_bsg_job_done(srb_t *sp, int);
extern void qla2x00_bsg_sp_free(srb_t *sp);
extern void qla2x00_start_iocbs(struct scsi_qla_host *, struct req_que *);

/* Interrupt related */
Expand Down
21 changes: 7 additions & 14 deletions drivers/scsi/qla2xxx/qla_gs.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,9 +499,8 @@ qla2x00_gnn_id(scsi_qla_host_t *vha, sw_info_t *list)
return (rval);
}

static void qla2x00_async_sns_sp_done(void *s, int rc)
static void qla2x00_async_sns_sp_done(srb_t *sp, int rc)
{
struct srb *sp = s;
struct scsi_qla_host *vha = sp->vha;
struct ct_sns_pkt *ct_sns;
struct qla_work_evt *e;
Expand Down Expand Up @@ -2989,9 +2988,8 @@ void qla24xx_handle_gpsc_event(scsi_qla_host_t *vha, struct event_arg *ea)
qla_post_iidma_work(vha, fcport);
}

static void qla24xx_async_gpsc_sp_done(void *s, int res)
static void qla24xx_async_gpsc_sp_done(srb_t *sp, int res)
{
struct srb *sp = s;
struct scsi_qla_host *vha = sp->vha;
struct qla_hw_data *ha = vha->hw;
fc_port_t *fcport = sp->fcport;
Expand Down Expand Up @@ -3258,9 +3256,8 @@ void qla24xx_handle_gpnid_event(scsi_qla_host_t *vha, struct event_arg *ea)
}
}

static void qla2x00_async_gpnid_sp_done(void *s, int res)
static void qla2x00_async_gpnid_sp_done(srb_t *sp, int res)
{
struct srb *sp = s;
struct scsi_qla_host *vha = sp->vha;
struct ct_sns_req *ct_req =
(struct ct_sns_req *)sp->u.iocb_cmd.u.ctarg.req;
Expand Down Expand Up @@ -3446,9 +3443,8 @@ void qla24xx_handle_gffid_event(scsi_qla_host_t *vha, struct event_arg *ea)
qla24xx_post_gnl_work(vha, fcport);
}

void qla24xx_async_gffid_sp_done(void *s, int res)
void qla24xx_async_gffid_sp_done(srb_t *sp, int res)
{
struct srb *sp = s;
struct scsi_qla_host *vha = sp->vha;
fc_port_t *fcport = sp->fcport;
struct ct_sns_rsp *ct_rsp;
Expand Down Expand Up @@ -3872,9 +3868,8 @@ static void qla2x00_find_free_fcp_nvme_slot(struct scsi_qla_host *vha,
}
}

static void qla2x00_async_gpnft_gnnft_sp_done(void *s, int res)
static void qla2x00_async_gpnft_gnnft_sp_done(srb_t *sp, int res)
{
struct srb *sp = s;
struct scsi_qla_host *vha = sp->vha;
struct ct_sns_req *ct_req =
(struct ct_sns_req *)sp->u.iocb_cmd.u.ctarg.req;
Expand Down Expand Up @@ -4251,9 +4246,8 @@ void qla24xx_handle_gnnid_event(scsi_qla_host_t *vha, struct event_arg *ea)
qla24xx_post_gnl_work(vha, ea->fcport);
}

static void qla2x00_async_gnnid_sp_done(void *s, int res)
static void qla2x00_async_gnnid_sp_done(srb_t *sp, int res)
{
struct srb *sp = s;
struct scsi_qla_host *vha = sp->vha;
fc_port_t *fcport = sp->fcport;
u8 *node_name = fcport->ct_desc.ct_sns->p.rsp.rsp.gnn_id.node_name;
Expand Down Expand Up @@ -4384,9 +4378,8 @@ void qla24xx_handle_gfpnid_event(scsi_qla_host_t *vha, struct event_arg *ea)
qla24xx_post_gpsc_work(vha, fcport);
}

static void qla2x00_async_gfpnid_sp_done(void *s, int res)
static void qla2x00_async_gfpnid_sp_done(srb_t *sp, int res)
{
struct srb *sp = s;
struct scsi_qla_host *vha = sp->vha;
fc_port_t *fcport = sp->fcport;
u8 *fpn = fcport->ct_desc.ct_sns->p.rsp.rsp.gfpn_id.port_name;
Expand Down
40 changes: 10 additions & 30 deletions drivers/scsi/qla2xxx/qla_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,8 @@ qla2x00_sp_timeout(struct timer_list *t)
iocb->timeout(sp);
}

void
qla2x00_sp_free(void *ptr)
void qla2x00_sp_free(srb_t *sp)
{
srb_t *sp = ptr;
struct srb_iocb *iocb = &sp->u.iocb_cmd;

del_timer(&iocb->timer);
Expand Down Expand Up @@ -117,9 +115,8 @@ static void qla24xx_abort_iocb_timeout(void *data)
sp->done(sp, QLA_OS_TIMER_EXPIRED);
}

static void qla24xx_abort_sp_done(void *ptr, int res)
static void qla24xx_abort_sp_done(srb_t *sp, int res)
{
srb_t *sp = ptr;
struct srb_iocb *abt = &sp->u.iocb_cmd;

del_timer(&sp->u.iocb_cmd.timer);
Expand Down Expand Up @@ -249,10 +246,8 @@ qla2x00_async_iocb_timeout(void *data)
}
}

static void
qla2x00_async_login_sp_done(void *ptr, int res)
static void qla2x00_async_login_sp_done(srb_t *sp, int res)
{
srb_t *sp = ptr;
struct scsi_qla_host *vha = sp->vha;
struct srb_iocb *lio = &sp->u.iocb_cmd;
struct event_arg ea;
Expand Down Expand Up @@ -358,11 +353,8 @@ qla2x00_async_login(struct scsi_qla_host *vha, fc_port_t *fcport,
return rval;
}

static void
qla2x00_async_logout_sp_done(void *ptr, int res)
static void qla2x00_async_logout_sp_done(srb_t *sp, int res)
{
srb_t *sp = ptr;

sp->fcport->flags &= ~(FCF_ASYNC_SENT | FCF_ASYNC_ACTIVE);
sp->fcport->login_gen++;
qlt_logo_completion_handler(sp->fcport, res);
Expand Down Expand Up @@ -419,10 +411,8 @@ qla2x00_async_prlo_done(struct scsi_qla_host *vha, fc_port_t *fcport,
qlt_logo_completion_handler(fcport, data[0]);
}

static void
qla2x00_async_prlo_sp_done(void *s, int res)
static void qla2x00_async_prlo_sp_done(srb_t *sp, int res)
{
srb_t *sp = (srb_t *)s;
struct srb_iocb *lio = &sp->u.iocb_cmd;
struct scsi_qla_host *vha = sp->vha;

Expand Down Expand Up @@ -525,10 +515,8 @@ static int qla_post_els_plogi_work(struct scsi_qla_host *vha, fc_port_t *fcport)
return qla2x00_post_work(vha, e);
}

static void
qla2x00_async_adisc_sp_done(void *ptr, int res)
static void qla2x00_async_adisc_sp_done(srb_t *sp, int res)
{
srb_t *sp = ptr;
struct scsi_qla_host *vha = sp->vha;
struct event_arg ea;
struct srb_iocb *lio = &sp->u.iocb_cmd;
Expand Down Expand Up @@ -931,10 +919,8 @@ static void qla24xx_handle_gnl_done_event(scsi_qla_host_t *vha,
}
} /* gnl_event */

static void
qla24xx_async_gnl_sp_done(void *s, int res)
static void qla24xx_async_gnl_sp_done(srb_t *sp, int res)
{
struct srb *sp = s;
struct scsi_qla_host *vha = sp->vha;
unsigned long flags;
struct fc_port *fcport = NULL, *tf;
Expand Down Expand Up @@ -1121,10 +1107,8 @@ int qla24xx_post_gnl_work(struct scsi_qla_host *vha, fc_port_t *fcport)
return qla2x00_post_work(vha, e);
}

static
void qla24xx_async_gpdb_sp_done(void *s, int res)
static void qla24xx_async_gpdb_sp_done(srb_t *sp, int res)
{
struct srb *sp = s;
struct scsi_qla_host *vha = sp->vha;
struct qla_hw_data *ha = vha->hw;
fc_port_t *fcport = sp->fcport;
Expand Down Expand Up @@ -1168,10 +1152,8 @@ static int qla24xx_post_prli_work(struct scsi_qla_host *vha, fc_port_t *fcport)
return qla2x00_post_work(vha, e);
}

static void
qla2x00_async_prli_sp_done(void *ptr, int res)
static void qla2x00_async_prli_sp_done(srb_t *sp, int res)
{
srb_t *sp = ptr;
struct scsi_qla_host *vha = sp->vha;
struct srb_iocb *lio = &sp->u.iocb_cmd;
struct event_arg ea;
Expand Down Expand Up @@ -1808,10 +1790,8 @@ qla2x00_tmf_iocb_timeout(void *data)
complete(&tmf->u.tmf.comp);
}

static void
qla2x00_tmf_sp_done(void *ptr, int res)
static void qla2x00_tmf_sp_done(srb_t *sp, int res)
{
srb_t *sp = ptr;
struct srb_iocb *tmf = &sp->u.iocb_cmd;

complete(&tmf->u.tmf.comp);
Expand Down
12 changes: 3 additions & 9 deletions drivers/scsi/qla2xxx/qla_iocb.c
Original file line number Diff line number Diff line change
Expand Up @@ -2544,10 +2544,8 @@ void qla2x00_init_timer(srb_t *sp, unsigned long tmo)
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);
Expand Down Expand Up @@ -2577,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;
Expand Down Expand Up @@ -2758,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;
Expand Down
4 changes: 1 addition & 3 deletions drivers/scsi/qla2xxx/qla_mbx.c
Original file line number Diff line number Diff line change
Expand Up @@ -6217,10 +6217,8 @@ qla26xx_dport_diagnostics(scsi_qla_host_t *vha,
return rval;
}

static void qla2x00_async_mb_sp_done(void *s, int res)
static void qla2x00_async_mb_sp_done(srb_t *sp, int res)
{
struct srb *sp = s;

sp->u.iocb_cmd.u.mbx.rc = res;

complete(&sp->u.iocb_cmd.u.mbx.comp);
Expand Down
4 changes: 1 addition & 3 deletions drivers/scsi/qla2xxx/qla_mid.c
Original file line number Diff line number Diff line change
Expand Up @@ -901,10 +901,8 @@ qla25xx_create_rsp_que(struct qla_hw_data *ha, uint16_t options,
return 0;
}

static void qla_ctrlvp_sp_done(void *s, int res)
static void qla_ctrlvp_sp_done(srb_t *sp, int res)
{
struct srb *sp = s;

if (sp->comp)
complete(sp->comp);
/* don't free sp here. Let the caller do the free */
Expand Down
4 changes: 1 addition & 3 deletions drivers/scsi/qla2xxx/qla_mr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1797,10 +1797,8 @@ qla2x00_fxdisc_iocb_timeout(void *data)
complete(&lio->u.fxiocb.fxiocb_comp);
}

static void
qla2x00_fxdisc_sp_done(void *ptr, int res)
static void qla2x00_fxdisc_sp_done(srb_t *sp, int res)
{
srb_t *sp = ptr;
struct srb_iocb *lio = &sp->u.iocb_cmd;

complete(&lio->u.fxiocb.fxiocb_comp);
Expand Down
11 changes: 4 additions & 7 deletions drivers/scsi/qla2xxx/qla_nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,28 +180,25 @@ static void qla_nvme_ls_complete(struct work_struct *work)
kref_put(&priv->sp->cmd_kref, qla_nvme_release_ls_cmd_kref);
}

static void qla_nvme_sp_ls_done(void *ptr, int res)
static void qla_nvme_sp_ls_done(srb_t *sp, int res)
{
srb_t *sp = ptr;
struct nvme_private *priv;
struct nvme_private *priv = sp->priv;

if (WARN_ON_ONCE(kref_read(&sp->cmd_kref) == 0))
return;

if (res)
res = -EINVAL;

priv = (struct nvme_private *)sp->priv;
priv->comp_status = res;
INIT_WORK(&priv->ls_work, qla_nvme_ls_complete);
schedule_work(&priv->ls_work);
}

/* it assumed that QPair lock is held. */
static void qla_nvme_sp_done(void *ptr, int res)
static void qla_nvme_sp_done(srb_t *sp, int res)
{
srb_t *sp = ptr;
struct nvme_private *priv = (struct nvme_private *)sp->priv;
struct nvme_private *priv = sp->priv;

priv->comp_status = res;
kref_put(&sp->cmd_kref, qla_nvme_release_fcp_cmd_kref);
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/qla2xxx/qla_nvme.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,5 @@ int qla_nvme_register_remote(struct scsi_qla_host *, struct fc_port *);
void qla_nvme_delete(struct scsi_qla_host *);
void qla24xx_nvme_ls4_iocb(struct scsi_qla_host *, struct pt_ls4_request *,
struct req_que *);
void qla24xx_async_gffid_sp_done(void *, int);
void qla24xx_async_gffid_sp_done(struct srb *sp, int);
#endif
Loading

0 comments on commit 6c18a43

Please sign in to comment.