diff mbox series

[37/52] scsi_debug: use scsi_build_sense()

Message ID 20191104090151.129140-38-hare@suse.de (mailing list archive)
State Deferred
Headers show
Series Revamp SCSI result values | expand

Commit Message

Hannes Reinecke Nov. 4, 2019, 9:01 a.m. UTC
Use scsi_build_sense() to format the sense code.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/scsi_debug.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

Comments

Douglas Gilbert Nov. 5, 2019, 6:03 a.m. UTC | #1
On 2019-11-04 4:01 a.m., Hannes Reinecke wrote:
> Use scsi_build_sense() to format the sense code.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.de>

Acked-by: Douglas Gilbert <dgilbert@interlog.com>

> ---
>   drivers/scsi/scsi_debug.c | 11 ++++-------
>   1 file changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
> index d323523f5f9d..72f10e631ff4 100644
> --- a/drivers/scsi/scsi_debug.c
> +++ b/drivers/scsi/scsi_debug.c
> @@ -779,7 +779,7 @@ static void mk_sense_invalid_fld(struct scsi_cmnd *scp,
>   	}
>   	asc = c_d ? INVALID_FIELD_IN_CDB : INVALID_FIELD_IN_PARAM_LIST;
>   	memset(sbuff, 0, SCSI_SENSE_BUFFERSIZE);
> -	scsi_build_sense_buffer(sdebug_dsense, sbuff, ILLEGAL_REQUEST, asc, 0);
> +	scsi_build_sense(scp, sdebug_dsense, ILLEGAL_REQUEST, asc, 0);
>   	memset(sks, 0, sizeof(sks));
>   	sks[0] = 0x80;
>   	if (c_d)
> @@ -805,17 +805,14 @@ static void mk_sense_invalid_fld(struct scsi_cmnd *scp,
>   
>   static void mk_sense_buffer(struct scsi_cmnd *scp, int key, int asc, int asq)
>   {
> -	unsigned char *sbuff;
> -
> -	sbuff = scp->sense_buffer;
> -	if (!sbuff) {
> +	if (!scp->sense_buffer) {
>   		sdev_printk(KERN_ERR, scp->device,
>   			    "%s: sense_buffer is NULL\n", __func__);
>   		return;
>   	}
> -	memset(sbuff, 0, SCSI_SENSE_BUFFERSIZE);
> +	memset(scp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
>   
> -	scsi_build_sense_buffer(sdebug_dsense, sbuff, key, asc, asq);
> +	scsi_build_sense(scp, sdebug_dsense, key, asc, asq);
>   
>   	if (sdebug_verbose)
>   		sdev_printk(KERN_INFO, scp->device,
>
diff mbox series

Patch

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index d323523f5f9d..72f10e631ff4 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -779,7 +779,7 @@  static void mk_sense_invalid_fld(struct scsi_cmnd *scp,
 	}
 	asc = c_d ? INVALID_FIELD_IN_CDB : INVALID_FIELD_IN_PARAM_LIST;
 	memset(sbuff, 0, SCSI_SENSE_BUFFERSIZE);
-	scsi_build_sense_buffer(sdebug_dsense, sbuff, ILLEGAL_REQUEST, asc, 0);
+	scsi_build_sense(scp, sdebug_dsense, ILLEGAL_REQUEST, asc, 0);
 	memset(sks, 0, sizeof(sks));
 	sks[0] = 0x80;
 	if (c_d)
@@ -805,17 +805,14 @@  static void mk_sense_invalid_fld(struct scsi_cmnd *scp,
 
 static void mk_sense_buffer(struct scsi_cmnd *scp, int key, int asc, int asq)
 {
-	unsigned char *sbuff;
-
-	sbuff = scp->sense_buffer;
-	if (!sbuff) {
+	if (!scp->sense_buffer) {
 		sdev_printk(KERN_ERR, scp->device,
 			    "%s: sense_buffer is NULL\n", __func__);
 		return;
 	}
-	memset(sbuff, 0, SCSI_SENSE_BUFFERSIZE);
+	memset(scp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
 
-	scsi_build_sense_buffer(sdebug_dsense, sbuff, key, asc, asq);
+	scsi_build_sense(scp, sdebug_dsense, key, asc, asq);
 
 	if (sdebug_verbose)
 		sdev_printk(KERN_INFO, scp->device,