diff mbox

[RFC,08/13] target: add helper to setup a se_cmd's sense

Message ID 1496263970-7632-9-git-send-email-mchristi@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mike Christie May 31, 2017, 8:52 p.m. UTC
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(-)
diff mbox

Patch

diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 62937cf..ad2132e 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -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;
 	}
diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h
index d7dd142..f0153dc 100644
--- a/include/target/target_core_fabric.h
+++ b/include/target/target_core_fabric.h
@@ -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);