diff mbox series

[16/39] scsi: add translate_msg_byte()

Message ID 20210423113944.42672-17-hare@suse.de
State New
Headers show
Series SCSI result cleanup, part 2 | expand

Commit Message

Hannes Reinecke April 23, 2021, 11:39 a.m. UTC
Add helper to convert message byte into a host byte code.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 include/scsi/scsi_cmnd.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Comments

Bart Van Assche April 26, 2021, 3:48 a.m. UTC | #1
On 4/23/21 4:39 AM, Hannes Reinecke wrote:
> Add helper to convert message byte into a host byte code.


Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Christoph Hellwig April 26, 2021, 3:24 p.m. UTC | #2
> +static inline void translate_msg_byte(struct scsi_cmnd *cmd, u8 msg)


I think a comment describing the function would be very helpful.
Also maybe scsi_message_to_host_byte might be a more descriptive name?
Hannes Reinecke April 26, 2021, 3:43 p.m. UTC | #3
On 4/26/21 5:24 PM, Christoph Hellwig wrote:
>> +static inline void translate_msg_byte(struct scsi_cmnd *cmd, u8 msg)

> 

> I think a comment describing the function would be very helpful.

> Also maybe scsi_message_to_host_byte might be a more descriptive name?

> 

Can do.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		        Kernel Storage Architect
hare@suse.de			               +49 911 74053 688
SUSE Software Solutions Germany GmbH, 90409 Nürnberg
GF: F. Imendörffer, HRB 36809 (AG Nürnberg)
diff mbox series

Patch

diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index 0ac18a7d8ac6..348bfa568f72 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -337,6 +337,23 @@  static inline unsigned char get_host_byte(struct scsi_cmnd *cmd)
 }
 
 
+static inline void translate_msg_byte(struct scsi_cmnd *cmd, u8 msg)
+{
+	switch (msg) {
+	case COMMAND_COMPLETE:
+		break;
+	case ABORT_TASK_SET:
+		set_host_byte(cmd, DID_ABORT);
+		break;
+	case TARGET_RESET:
+		set_host_byte(cmd, DID_RESET);
+		break;
+	default:
+		set_host_byte(cmd, DID_ERROR);
+		break;
+	}
+}
+
 static inline unsigned scsi_transfer_length(struct scsi_cmnd *scmd)
 {
 	unsigned int xfer_len = scmd->sdb.length;