@@ -3036,6 +3036,15 @@ static int translate_sense_reason(struct se_cmd *cmd, sense_reason_t reason)
return 0;
}
+int transport_setup_sense(struct se_cmd *cmd, sense_reason_t reason)
+{
+ cmd->se_cmd_flags |= SCF_TASK_SENSE;
+ cmd->scsi_status = SAM_STAT_CHECK_CONDITION;
+ cmd->scsi_sense_length = TRANSPORT_SENSE_BUFFER;
+ return translate_sense_reason(cmd, reason);
+}
+EXPORT_SYMBOL(transport_setup_sense);
+
int
transport_send_check_condition_and_sense(struct se_cmd *cmd,
sense_reason_t reason, int from_transport)
@@ -3053,10 +3062,7 @@ static int translate_sense_reason(struct se_cmd *cmd, sense_reason_t reason)
if (!from_transport) {
int rc;
- cmd->se_cmd_flags |= SCF_TASK_SENSE;
- cmd->scsi_status = SAM_STAT_CHECK_CONDITION;
- cmd->scsi_sense_length = TRANSPORT_SENSE_BUFFER;
- rc = translate_sense_reason(cmd, reason);
+ rc = transport_setup_sense(cmd, reason);
if (rc)
return rc;
}
@@ -154,6 +154,7 @@ int target_submit_tmr(struct se_cmd *se_cmd, struct se_session *se_sess,
bool transport_wait_for_tasks(struct se_cmd *);
int transport_check_aborted_status(struct se_cmd *, int);
+int transport_setup_sense(struct se_cmd *, sense_reason_t);
int transport_send_check_condition_and_sense(struct se_cmd *,
sense_reason_t, int);
int target_get_sess_cmd(struct se_cmd *, bool);
Move sense setup from transport_send_check_condition_and_sense to a new helper. The next patch will convert usb f_tcm to use it. Signed-off-by: Mike Christie <mchristi@redhat.com> --- drivers/target/target_core_transport.c | 14 ++++++++++---- include/target/target_core_fabric.h | 1 + 2 files changed, 11 insertions(+), 4 deletions(-)