diff mbox series

[1/4] scsi: Introduct scsi_cmd_to_tag()

Message ID 20210819084007.79233-2-hare@suse.de (mailing list archive)
State Changes Requested
Headers show
Series scsi: remove last references to scsi_cmnd.tag | expand

Commit Message

Hannes Reinecke Aug. 19, 2021, 8:40 a.m. UTC
Introduce a wrapper to get the tag from a SCSI command.

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

Comments

John Garry Aug. 19, 2021, 10:57 a.m. UTC | #1
On 19/08/2021 09:40, Hannes Reinecke wrote:
> Introduce a wrapper to get the tag from a SCSI command.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> ---
>   include/scsi/scsi_cmnd.h | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
> index eaf04c9a1dfc..f3cc3aa0eb04 100644
> --- a/include/scsi/scsi_cmnd.h
> +++ b/include/scsi/scsi_cmnd.h
> @@ -165,6 +165,13 @@ static inline struct scsi_driver *scsi_cmd_to_driver(struct scsi_cmnd *cmd)
>   	return *(struct scsi_driver **)rq->rq_disk->private_data;
>   }
>   
> +static inline u32 scsi_cmd_to_tag(struct scsi_cmnd *cmd)

I'd call it scsi_cmd_to_rq_tag(), especially since scsi_cmnd.tag is 
hanging for dear life and I assume you want this helper regardless of 
what happens there, but it's just a name...

> +{
> +	struct request *rq = scsi_cmd_to_rq(cmd);
> +
> +	return rq->tag; > +}
> +
>   extern void scsi_finish_command(struct scsi_cmnd *cmd);
>   
>   extern void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count,
> 

Reviewed-by: John Garry <john.garry@huawei.com>
Bart Van Assche Aug. 19, 2021, 4:59 p.m. UTC | #2
On 8/19/21 1:40 AM, Hannes Reinecke wrote:
> +static inline u32 scsi_cmd_to_tag(struct scsi_cmnd *cmd)
> +{
> +	struct request *rq = scsi_cmd_to_rq(cmd);
> +
> +	return rq->tag;
> +}

Do we really need this function? If so, please change "Introduct" in the 
subject into "Introduce". Additionally, how about renaming this function 
into scsi_cmd_tag()? How about changing the function body into "return 
scsi_cmd_to_rq(cmd)->tag"?

Thanks,

Bart.
diff mbox series

Patch

diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index eaf04c9a1dfc..f3cc3aa0eb04 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -165,6 +165,13 @@  static inline struct scsi_driver *scsi_cmd_to_driver(struct scsi_cmnd *cmd)
 	return *(struct scsi_driver **)rq->rq_disk->private_data;
 }
 
+static inline u32 scsi_cmd_to_tag(struct scsi_cmnd *cmd)
+{
+	struct request *rq = scsi_cmd_to_rq(cmd);
+
+	return rq->tag;
+}
+
 extern void scsi_finish_command(struct scsi_cmnd *cmd);
 
 extern void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count,