diff mbox series

[v2,07/15] scsi: spi: Convert to scsi_execute_args

Message ID 20221209061325.705999-8-michael.christie@oracle.com (mailing list archive)
State Superseded
Headers show
Series scsi: Add struct for args to execution functions | expand

Commit Message

Mike Christie Dec. 9, 2022, 6:13 a.m. UTC
scsi_execute is going to be removed. Convert to the SPI class to
scsi_execute_args.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
 drivers/scsi/scsi_transport_spi.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

Comments

John Garry Dec. 9, 2022, 10:10 a.m. UTC | #1
On 09/12/2022 06:13, Mike Christie wrote:
> scsi_execute is going to be removed. Convert to the SPI class to
> scsi_execute_args.
> 
> Signed-off-by: Mike Christie<michael.christie@oracle.com>

FWIW, Apart from nit:

Reviewed-by: John Garry <john.g.garry@oracle.com>

> ---
>   drivers/scsi/scsi_transport_spi.c | 28 ++++++++++++++--------------
>   1 file changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
> index f569cf0095c2..fa06821f3cb6 100644
> --- a/drivers/scsi/scsi_transport_spi.c
> +++ b/drivers/scsi/scsi_transport_spi.c
> @@ -105,28 +105,28 @@ static int sprint_frac(char *dest, int value, int denom)
>   }
>   
>   static int spi_execute(struct scsi_device *sdev, const void *cmd,
> -		       enum dma_data_direction dir,
> -		       void *buffer, unsigned bufflen,
> +		       enum req_op op, void *buffer, unsigned int bufflen,
>   		       struct scsi_sense_hdr *sshdr)
>   {
>   	int i, result;
> -	unsigned char sense[SCSI_SENSE_BUFFERSIZE];
>   	struct scsi_sense_hdr sshdr_tmp;
> +	blk_opf_t opf = op | REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT |
> +			REQ_FAILFAST_DRIVER;
> +	struct scsi_exec_args exec_args = {
> +		.req_flags = BLK_MQ_REQ_PM,

I think that .sshdr could still be assigned here, like:
		.sshdr = sshdr ? : &sshdr_tmp;

I think that is the proper syntax.

> +	};
>   
>   	if (!sshdr)
>   		sshdr = &sshdr_tmp;
> +	exec_args.sshdr = sshdr;
Bart Van Assche Dec. 12, 2022, 9:16 p.m. UTC | #2
On 12/9/22 02:10, John Garry wrote:
> On 09/12/2022 06:13, Mike Christie wrote:
>> +    blk_opf_t opf = op | REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT |
>> +            REQ_FAILFAST_DRIVER;
>> +    struct scsi_exec_args exec_args = {
>> +        .req_flags = BLK_MQ_REQ_PM,
> 
> I think that .sshdr could still be assigned here, like:
>          .sshdr = sshdr ? : &sshdr_tmp;

That seems like an improvement to me. Once the above suggestion has been
applied, please add:

Reviewed-by: Bart Van Assche <bvanassche@acm.org>
diff mbox series

Patch

diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
index f569cf0095c2..fa06821f3cb6 100644
--- a/drivers/scsi/scsi_transport_spi.c
+++ b/drivers/scsi/scsi_transport_spi.c
@@ -105,28 +105,28 @@  static int sprint_frac(char *dest, int value, int denom)
 }
 
 static int spi_execute(struct scsi_device *sdev, const void *cmd,
-		       enum dma_data_direction dir,
-		       void *buffer, unsigned bufflen,
+		       enum req_op op, void *buffer, unsigned int bufflen,
 		       struct scsi_sense_hdr *sshdr)
 {
 	int i, result;
-	unsigned char sense[SCSI_SENSE_BUFFERSIZE];
 	struct scsi_sense_hdr sshdr_tmp;
+	blk_opf_t opf = op | REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT |
+			REQ_FAILFAST_DRIVER;
+	struct scsi_exec_args exec_args = {
+		.req_flags = BLK_MQ_REQ_PM,
+	};
 
 	if (!sshdr)
 		sshdr = &sshdr_tmp;
+	exec_args.sshdr = sshdr;
 
 	for(i = 0; i < DV_RETRIES; i++) {
 		/*
 		 * The purpose of the RQF_PM flag below is to bypass the
 		 * SDEV_QUIESCE state.
 		 */
-		result = scsi_execute(sdev, cmd, dir, buffer, bufflen, sense,
-				      sshdr, DV_TIMEOUT, /* retries */ 1,
-				      REQ_FAILFAST_DEV |
-				      REQ_FAILFAST_TRANSPORT |
-				      REQ_FAILFAST_DRIVER,
-				      RQF_PM, NULL);
+		result = scsi_execute_args(sdev, cmd, opf, buffer, bufflen,
+					   DV_TIMEOUT, 1, exec_args);
 		if (result < 0 || !scsi_sense_valid(sshdr) ||
 		    sshdr->sense_key != UNIT_ATTENTION)
 			break;
@@ -675,7 +675,7 @@  spi_dv_device_echo_buffer(struct scsi_device *sdev, u8 *buffer,
 	}
 
 	for (r = 0; r < retries; r++) {
-		result = spi_execute(sdev, spi_write_buffer, DMA_TO_DEVICE,
+		result = spi_execute(sdev, spi_write_buffer, REQ_OP_DRV_OUT,
 				     buffer, len, &sshdr);
 		if(result || !scsi_device_online(sdev)) {
 
@@ -697,7 +697,7 @@  spi_dv_device_echo_buffer(struct scsi_device *sdev, u8 *buffer,
 		}
 
 		memset(ptr, 0, len);
-		spi_execute(sdev, spi_read_buffer, DMA_FROM_DEVICE,
+		spi_execute(sdev, spi_read_buffer, REQ_OP_DRV_IN,
 			    ptr, len, NULL);
 		scsi_device_set_state(sdev, SDEV_QUIESCE);
 
@@ -722,7 +722,7 @@  spi_dv_device_compare_inquiry(struct scsi_device *sdev, u8 *buffer,
 	for (r = 0; r < retries; r++) {
 		memset(ptr, 0, len);
 
-		result = spi_execute(sdev, spi_inquiry, DMA_FROM_DEVICE,
+		result = spi_execute(sdev, spi_inquiry, REQ_OP_DRV_IN,
 				     ptr, len, NULL);
 		
 		if(result || !scsi_device_online(sdev)) {
@@ -828,7 +828,7 @@  spi_dv_device_get_echo_buffer(struct scsi_device *sdev, u8 *buffer)
 	 * (reservation conflict, device not ready, etc) just
 	 * skip the write tests */
 	for (l = 0; ; l++) {
-		result = spi_execute(sdev, spi_test_unit_ready, DMA_NONE, 
+		result = spi_execute(sdev, spi_test_unit_ready, REQ_OP_DRV_IN,
 				     NULL, 0, NULL);
 
 		if(result) {
@@ -841,7 +841,7 @@  spi_dv_device_get_echo_buffer(struct scsi_device *sdev, u8 *buffer)
 	}
 
 	result = spi_execute(sdev, spi_read_buffer_descriptor, 
-			     DMA_FROM_DEVICE, buffer, 4, NULL);
+			     REQ_OP_DRV_IN, buffer, 4, NULL);
 
 	if (result)
 		/* Device has no echo buffer */