From dd52454052061959d25623500e48032f5ee3b206 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 21 Aug 2019 21:30:39 +0000 Subject: [PATCH] scst: Introduce struct scst_icmd_priv This patch does not change any functionality but improves source code readability. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8511 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_copy_mgr.c | 3 ++- scst/src/scst_lib.c | 10 ++++------ scst/src/scst_priv.h | 5 +++++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/scst/src/scst_copy_mgr.c b/scst/src/scst_copy_mgr.c index eda4dfd6a..562c5e309 100644 --- a/scst/src/scst_copy_mgr.c +++ b/scst/src/scst_copy_mgr.c @@ -3726,8 +3726,9 @@ static int scst_cm_release(struct scst_tgt *tgt) static int scst_cm_xmit_response(struct scst_cmd *cmd) { + struct scst_icmd_priv *icmd_priv = cmd->tgt_i_priv; + scst_i_finish_fn_t f = icmd_priv->finish_fn; int res = SCST_TGT_RES_SUCCESS; - scst_i_finish_fn_t f = (void *) *((unsigned long long **)cmd->tgt_i_priv); TRACE_ENTRY(); diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 31c8cb443..9e5617d83 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -6944,8 +6944,9 @@ out_done: int scst_finish_internal_cmd(struct scst_cmd *cmd) { - int res; + struct scst_icmd_priv *icmd_priv = cmd->tgt_i_priv; unsigned long flags; + int res; TRACE_ENTRY(); @@ -6971,11 +6972,8 @@ int scst_finish_internal_cmd(struct scst_cmd *cmd) if (cmd->cdb[0] == REQUEST_SENSE) scst_complete_request_sense(cmd); - else { - scst_i_finish_fn_t f = (void *) *((unsigned long long **)cmd->tgt_i_priv); - - f(cmd); - } + else + icmd_priv->finish_fn(cmd); __scst_cmd_put(cmd); diff --git a/scst/src/scst_priv.h b/scst/src/scst_priv.h index 20756def1..4b30dde37 100644 --- a/scst/src/scst_priv.h +++ b/scst/src/scst_priv.h @@ -157,6 +157,11 @@ static inline void scst_set_cmd_state(struct scst_cmd *cmd, typedef void (*scst_i_finish_fn_t) (struct scst_cmd *cmd); +/* Private data associated with an internal command. */ +struct scst_icmd_priv { + scst_i_finish_fn_t finish_fn; +}; + extern struct mutex scst_mutex2; extern int scst_threads;