diff --git a/scst/include/scst.h b/scst/include/scst.h index e9e8c5dc9..b0cd1e388 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -3958,6 +3958,12 @@ static inline bool scst_cmd_atomic(struct scst_cmd *cmd) return res; } +/* Returns TRUE if cmd completed with SAM_STAT_GOOD */ +static inline bool scst_cmd_completed_good(struct scst_cmd *cmd) +{ + return cmd->completed && (cmd->status == SAM_STAT_GOOD); +} + /* * Returns TRUE if cmd has been preliminary completed, i.e. completed or * aborted. diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 3f38d6d60..79e1a9588 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -10933,7 +10933,6 @@ int scst_block_generic_dev_done(struct scst_cmd *cmd, void (*set_block_shift)(struct scst_cmd *cmd, int block_shift)) { int opcode = cmd->cdb[0]; - int status = cmd->status; int res = SCST_CMD_STATE_DEFAULT; TRACE_ENTRY(); @@ -10945,7 +10944,7 @@ int scst_block_generic_dev_done(struct scst_cmd *cmd, */ if (unlikely(opcode == READ_CAPACITY)) { - if ((status == SAM_STAT_GOOD) || (status == SAM_STAT_CONDITION_MET)) { + if (scst_cmd_completed_good(cmd)) { /* Always keep track of disk capacity */ int buffer_size, sector_size, sh; uint8_t *buffer; @@ -11003,7 +11002,7 @@ int scst_tape_generic_dev_done(struct scst_cmd *cmd, * therefore change them only if necessary */ - if (unlikely(cmd->status != SAM_STAT_GOOD)) + if (unlikely(!scst_cmd_completed_good(cmd))) goto out; switch (opcode) { diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index 6f97d960a..9dd794190 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -3590,7 +3590,7 @@ next: goto out; } - if (likely(cmd->status == SAM_STAT_GOOD)) { + if (likely(scst_cmd_completed_good(cmd))) { if (cmd->deferred_dif_read_check) { int rc = scst_dif_process_read(cmd); if (unlikely(rc != 0)) {