[02/10] scsi: remove scsi_init_cmd_errh

Message ID 20201005084130.143273-3-hch@lst.de
State New
Headers show
Series
  • [01/10] scsi: don't export scsi_device_from_queue
Related show

Commit Message

Christoph Hellwig Oct. 5, 2020, 8:41 a.m.
There is no good reason to keep this functionality as a separate
function, just merge it into the only caller.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/scsi/scsi_lib.c | 20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)

Comments

Hannes Reinecke Oct. 5, 2020, 9:01 a.m. | #1
On 10/5/20 10:41 AM, Christoph Hellwig wrote:
> There is no good reason to keep this functionality as a separate

> function, just merge it into the only caller.

> 

> Signed-off-by: Christoph Hellwig <hch@lst.de>

> ---

>   drivers/scsi/scsi_lib.c | 20 ++++----------------

>   1 file changed, 4 insertions(+), 16 deletions(-)

> 

> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c

> index b95e00ff346b09..8a7ae46b5943da 100644

> --- a/drivers/scsi/scsi_lib.c

> +++ b/drivers/scsi/scsi_lib.c

> @@ -293,21 +293,6 @@ int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,

>   }

>   EXPORT_SYMBOL(__scsi_execute);

>   

> -/**

> - * scsi_init_cmd_errh - Initialize cmd fields related to error handling.

> - * @cmd:  command that is ready to be queued.

> - *

> - * This function has the job of initializing a number of fields related to error

> - * handling. Typically this will be called once for each command, as required.

> - */

> -static void scsi_init_cmd_errh(struct scsi_cmnd *cmd)

> -{

> -	scsi_set_resid(cmd, 0);

> -	memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);

> -	if (cmd->cmd_len == 0)

> -		cmd->cmd_len = scsi_command_size(cmd->cmnd);

> -}

> -

>   /*

>    * Wake up the error handler if necessary. Avoid as follows that the error

>    * handler is not woken up if host in-flight requests number ==

> @@ -1698,7 +1683,10 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx,

>   	if (bd->last)

>   		cmd->flags |= SCMD_LAST;

>   

> -	scsi_init_cmd_errh(cmd);

> +	scsi_set_resid(cmd, 0);

> +	memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);

> +	if (cmd->cmd_len == 0)

> +		cmd->cmd_len = scsi_command_size(cmd->cmnd);

>   	cmd->scsi_done = scsi_mq_done;

>   

>   	reason = scsi_dispatch_cmd(cmd);

> 

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


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

Patch

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index b95e00ff346b09..8a7ae46b5943da 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -293,21 +293,6 @@  int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
 }
 EXPORT_SYMBOL(__scsi_execute);
 
-/**
- * scsi_init_cmd_errh - Initialize cmd fields related to error handling.
- * @cmd:  command that is ready to be queued.
- *
- * This function has the job of initializing a number of fields related to error
- * handling. Typically this will be called once for each command, as required.
- */
-static void scsi_init_cmd_errh(struct scsi_cmnd *cmd)
-{
-	scsi_set_resid(cmd, 0);
-	memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
-	if (cmd->cmd_len == 0)
-		cmd->cmd_len = scsi_command_size(cmd->cmnd);
-}
-
 /*
  * Wake up the error handler if necessary. Avoid as follows that the error
  * handler is not woken up if host in-flight requests number ==
@@ -1698,7 +1683,10 @@  static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx,
 	if (bd->last)
 		cmd->flags |= SCMD_LAST;
 
-	scsi_init_cmd_errh(cmd);
+	scsi_set_resid(cmd, 0);
+	memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
+	if (cmd->cmd_len == 0)
+		cmd->cmd_len = scsi_command_size(cmd->cmnd);
 	cmd->scsi_done = scsi_mq_done;
 
 	reason = scsi_dispatch_cmd(cmd);