diff mbox series

[05/24] scsi: add scsi_cmd_from_priv()

Message ID 20190529132901.27645-6-hare@suse.de (mailing list archive)
State Changes Requested
Headers show
Series scsi: enable reserved commands for LLDDs | expand

Commit Message

Hannes Reinecke May 29, 2019, 1:28 p.m. UTC
Add a command to retrieve the scsi_cmnd structure from the driver
private allocation data.

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

Comments

Bart Van Assche May 29, 2019, 3:14 p.m. UTC | #1
On 5/29/19 6:28 AM, Hannes Reinecke wrote:
> Add a command to retrieve the scsi_cmnd structure from the driver
         ^^^^^^^
         function?
> private allocation data.
Hannes Reinecke May 29, 2019, 5:34 p.m. UTC | #2
On 5/29/19 5:14 PM, Bart Van Assche wrote:
> On 5/29/19 6:28 AM, Hannes Reinecke wrote:
>> Add a command to retrieve the scsi_cmnd structure from the driver
>          ^^^^^^^
>          function?
>> private allocation data.
Sure.

Cheers,

Hannes
diff mbox series

Patch

diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index 76ed5e4acd38..318f1e729318 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -151,6 +151,16 @@  static inline void *scsi_cmd_priv(struct scsi_cmnd *cmd)
 	return cmd + 1;
 }
 
+/*
+ * Return the scsi_cmnd structure located before the driver
+ * private allocation. Only works if cmd_size is set in the
+ * host template.
+ */
+static inline struct scsi_cmnd *scsi_cmd_from_priv(void *priv)
+{
+	return priv - sizeof(struct scsi_cmnd);
+}
+
 /* make sure not to use it with passthrough commands */
 static inline struct scsi_driver *scsi_cmd_to_driver(struct scsi_cmnd *cmd)
 {