diff mbox series

[16/44] esp_scsi: Stop using the SCSI pointer

Message ID 20220128221909.8141-17-bvanassche@acm.org
State New
Headers show
Series Remove the SCSI pointer from struct scsi_cmnd | expand

Commit Message

Bart Van Assche Jan. 28, 2022, 10:18 p.m. UTC
Set .cmd_size in the SCSI host template instead of using the SCSI pointer
from struct scsi_cmnd. This patch prepares for removal of the SCSI pointer
from struct scsi_cmnd.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/esp_scsi.c | 1 +
 drivers/scsi/esp_scsi.h | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

Comments

Johannes Thumshirn Jan. 31, 2022, 10:43 a.m. UTC | #1
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Finn Thain Jan. 31, 2022, 10:46 p.m. UTC | #2
On Fri, 28 Jan 2022, Bart Van Assche wrote:

> Set .cmd_size in the SCSI host template instead of using the SCSI pointer
> from struct scsi_cmnd. This patch prepares for removal of the SCSI pointer
> from struct scsi_cmnd.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/scsi/esp_scsi.c | 1 +
>  drivers/scsi/esp_scsi.h | 3 ++-
>  2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c
> index 57787537285a..9dfdca5b31e7 100644
> --- a/drivers/scsi/esp_scsi.c
> +++ b/drivers/scsi/esp_scsi.c
> @@ -2678,6 +2678,7 @@ struct scsi_host_template scsi_esp_template = {
>  	.sg_tablesize		= SG_ALL,
>  	.max_sectors		= 0xffff,
>  	.skip_settle_delay	= 1,
> +	.cmd_size		= sizeof(struct esp_cmd_priv),
>  };
>  EXPORT_SYMBOL(scsi_esp_template);
>  
> diff --git a/drivers/scsi/esp_scsi.h b/drivers/scsi/esp_scsi.h
> index 446a3d18c022..c73760d3cf83 100644
> --- a/drivers/scsi/esp_scsi.h
> +++ b/drivers/scsi/esp_scsi.h
> @@ -262,7 +262,8 @@ struct esp_cmd_priv {
>  	struct scatterlist	*cur_sg;
>  	int			tot_residue;
>  };
> -#define ESP_CMD_PRIV(CMD)	((struct esp_cmd_priv *)(&(CMD)->SCp))
> +
> +#define ESP_CMD_PRIV(cmd)	((struct esp_cmd_priv *)scsi_cmd_priv(cmd))
>  
>  /* NOTE: this enum is ordered based on chip features! */
>  enum esp_rev {
> 

After that, you're free to do this:

diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c
index bb88995a12c7..4934a5490716 100644
--- a/drivers/scsi/esp_scsi.c
+++ b/drivers/scsi/esp_scsi.c
@@ -2746,9 +2746,6 @@ static struct spi_function_template esp_transport_ops = {
 
 static int __init esp_init(void)
 {
-	BUILD_BUG_ON(sizeof(struct scsi_pointer) <
-		     sizeof(struct esp_cmd_priv));
-
 	esp_transport_template = spi_attach_transport(&esp_transport_ops);
 	if (!esp_transport_template)
 		return -ENODEV;
Bart Van Assche Feb. 1, 2022, 9:20 p.m. UTC | #3
On 1/31/22 14:46, Finn Thain wrote:
> After that, you're free to do this:
> 
> diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c
> index bb88995a12c7..4934a5490716 100644
> --- a/drivers/scsi/esp_scsi.c
> +++ b/drivers/scsi/esp_scsi.c
> @@ -2746,9 +2746,6 @@ static struct spi_function_template esp_transport_ops = {
>   
>   static int __init esp_init(void)
>   {
> -	BUILD_BUG_ON(sizeof(struct scsi_pointer) <
> -		     sizeof(struct esp_cmd_priv));
> -
>   	esp_transport_template = spi_attach_transport(&esp_transport_ops);
>   	if (!esp_transport_template)
>   		return -ENODEV;

Right, that BUILD_BUG_ON() statement can now be removed. I will check 
for are similar statements in other SCSI drivers too.

Thanks,

Bart.
diff mbox series

Patch

diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c
index 57787537285a..9dfdca5b31e7 100644
--- a/drivers/scsi/esp_scsi.c
+++ b/drivers/scsi/esp_scsi.c
@@ -2678,6 +2678,7 @@  struct scsi_host_template scsi_esp_template = {
 	.sg_tablesize		= SG_ALL,
 	.max_sectors		= 0xffff,
 	.skip_settle_delay	= 1,
+	.cmd_size		= sizeof(struct esp_cmd_priv),
 };
 EXPORT_SYMBOL(scsi_esp_template);
 
diff --git a/drivers/scsi/esp_scsi.h b/drivers/scsi/esp_scsi.h
index 446a3d18c022..c73760d3cf83 100644
--- a/drivers/scsi/esp_scsi.h
+++ b/drivers/scsi/esp_scsi.h
@@ -262,7 +262,8 @@  struct esp_cmd_priv {
 	struct scatterlist	*cur_sg;
 	int			tot_residue;
 };
-#define ESP_CMD_PRIV(CMD)	((struct esp_cmd_priv *)(&(CMD)->SCp))
+
+#define ESP_CMD_PRIV(cmd)	((struct esp_cmd_priv *)scsi_cmd_priv(cmd))
 
 /* NOTE: this enum is ordered based on chip features! */
 enum esp_rev {