diff mbox series

[13/42] scsi: add get_{status,host}_byte() accessor function

Message ID 20210421174749.11221-14-hare@suse.de
State Superseded
Headers show
Series SCSI result cleanup, part 2 | expand

Commit Message

Hannes Reinecke April 21, 2021, 5:47 p.m. UTC
Add accessor functions for the host and status byte.

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

Comments

Bart Van Assche April 21, 2021, 9:09 p.m. UTC | #1
On 4/21/21 10:47 AM, Hannes Reinecke wrote:
> Add accessor functions for the host and status byte.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> ---
>   include/scsi/scsi_cmnd.h | 10 ++++++++++
>   1 file changed, 10 insertions(+)
> 
> diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
> index a1eb7732aa1b..0ac18a7d8ac6 100644
> --- a/include/scsi/scsi_cmnd.h
> +++ b/include/scsi/scsi_cmnd.h
> @@ -316,6 +316,11 @@ static inline void set_status_byte(struct scsi_cmnd *cmd, char status)
>   	cmd->result = (cmd->result & 0xffffff00) | status;
>   }
>   
> +static inline unsigned char get_status_byte(struct scsi_cmnd *cmd)
> +{
> +	return cmd->result & 0xff;
> +}

So in addition to the status_byte() macro, get_status_byte() is 
introduced? That seems like a potential source of confusion to me.

Thanks,

Bart.
Hannes Reinecke April 22, 2021, 6:33 a.m. UTC | #2
On 4/21/21 11:09 PM, Bart Van Assche wrote:
> On 4/21/21 10:47 AM, Hannes Reinecke wrote:

>> Add accessor functions for the host and status byte.

>>

>> Signed-off-by: Hannes Reinecke <hare@suse.de>

>> ---

>>   include/scsi/scsi_cmnd.h | 10 ++++++++++

>>   1 file changed, 10 insertions(+)

>>

>> diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h

>> index a1eb7732aa1b..0ac18a7d8ac6 100644

>> --- a/include/scsi/scsi_cmnd.h

>> +++ b/include/scsi/scsi_cmnd.h

>> @@ -316,6 +316,11 @@ static inline void set_status_byte(struct 

>> scsi_cmnd *cmd, char status)

>>       cmd->result = (cmd->result & 0xffffff00) | status;

>>   }

>> +static inline unsigned char get_status_byte(struct scsi_cmnd *cmd)

>> +{

>> +    return cmd->result & 0xff;

>> +}

> 

> So in addition to the status_byte() macro, get_status_byte() is 

> introduced? That seems like a potential source of confusion to me.

> 

The idea is to kill 'status_byte' (and the linux-specific status codes) 
entirely, which then would resolve this ambiguity.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                Kernel Storage Architect
hare@suse.de                              +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
diff mbox series

Patch

diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index a1eb7732aa1b..0ac18a7d8ac6 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -316,6 +316,11 @@  static inline void set_status_byte(struct scsi_cmnd *cmd, char status)
 	cmd->result = (cmd->result & 0xffffff00) | status;
 }
 
+static inline unsigned char get_status_byte(struct scsi_cmnd *cmd)
+{
+	return cmd->result & 0xff;
+}
+
 static inline void set_msg_byte(struct scsi_cmnd *cmd, char status)
 {
 	cmd->result = (cmd->result & 0xffff00ff) | (status << 8);
@@ -326,6 +331,11 @@  static inline void set_host_byte(struct scsi_cmnd *cmd, char status)
 	cmd->result = (cmd->result & 0xff00ffff) | (status << 16);
 }
 
+static inline unsigned char get_host_byte(struct scsi_cmnd *cmd)
+{
+	return (cmd->result >> 16) & 0xff;
+}
+
 
 static inline unsigned scsi_transfer_length(struct scsi_cmnd *scmd)
 {