diff mbox series

[2/5] scsi_debug: Use scsi_[gs]et_resid() where appropriate

Message ID 20190208212503.237150-3-bvanassche@acm.org (mailing list archive)
State Mainlined
Commit 42d387be5bdaa29f416e0ff210616538e92d6b94
Headers show
Series Reduce the size of the SCSI request data structure | expand

Commit Message

Bart Van Assche Feb. 8, 2019, 9:25 p.m. UTC
This patch does not change any functionality.

Cc: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/scsi_debug.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Douglas Gilbert Feb. 9, 2019, 11:31 p.m. UTC | #1
On 2019-02-08 4:25 p.m., Bart Van Assche wrote:
> This patch does not change any functionality.
> 
> Cc: Douglas Gilbert <dgilbert@interlog.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Acked-by: Douglas Gilbert <dgilbert@interlog.com>

> ---
>   drivers/scsi/scsi_debug.c | 9 +++++----
>   1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
> index 5800f0b06a8d..60c194af7563 100644
> --- a/drivers/scsi/scsi_debug.c
> +++ b/drivers/scsi/scsi_debug.c
> @@ -1014,7 +1014,7 @@ static int fill_from_dev_buffer(struct scsi_cmnd *scp, unsigned char *arr,
>   
>   	act_len = sg_copy_from_buffer(sdb->table.sgl, sdb->table.nents,
>   				      arr, arr_len);
> -	sdb->resid = scsi_bufflen(scp) - act_len;
> +	scsi_set_resid(scp, scsi_bufflen(scp) - act_len);
>   
>   	return 0;
>   }
> @@ -1039,9 +1039,10 @@ static int p_fill_from_dev_buffer(struct scsi_cmnd *scp, const void *arr,
>   	act_len = sg_pcopy_from_buffer(sdb->table.sgl, sdb->table.nents,
>   				       arr, arr_len, skip);
>   	pr_debug("%s: off_dst=%u, scsi_bufflen=%u, act_len=%u, resid=%d\n",
> -		 __func__, off_dst, scsi_bufflen(scp), act_len, sdb->resid);
> +		 __func__, off_dst, scsi_bufflen(scp), act_len,
> +		 scsi_get_resid(scp));
>   	n = (int)scsi_bufflen(scp) - ((int)off_dst + act_len);
> -	sdb->resid = min(sdb->resid, n);
> +	scsi_set_resid(scp, min(scsi_get_resid(scp), n));
>   	return 0;
>   }
>   
> @@ -2767,7 +2768,7 @@ static int resp_read_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)
>   	if (unlikely(ret == -1))
>   		return DID_ERROR << 16;
>   
> -	scp->sdb.resid = scsi_bufflen(scp) - ret;
> +	scsi_set_resid(scp, scsi_bufflen(scp) - ret);
>   
>   	if (unlikely(sqcp)) {
>   		if (sqcp->inj_recovered) {
>
Christoph Hellwig Feb. 12, 2019, 7:57 a.m. UTC | #2
Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 5800f0b06a8d..60c194af7563 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -1014,7 +1014,7 @@  static int fill_from_dev_buffer(struct scsi_cmnd *scp, unsigned char *arr,
 
 	act_len = sg_copy_from_buffer(sdb->table.sgl, sdb->table.nents,
 				      arr, arr_len);
-	sdb->resid = scsi_bufflen(scp) - act_len;
+	scsi_set_resid(scp, scsi_bufflen(scp) - act_len);
 
 	return 0;
 }
@@ -1039,9 +1039,10 @@  static int p_fill_from_dev_buffer(struct scsi_cmnd *scp, const void *arr,
 	act_len = sg_pcopy_from_buffer(sdb->table.sgl, sdb->table.nents,
 				       arr, arr_len, skip);
 	pr_debug("%s: off_dst=%u, scsi_bufflen=%u, act_len=%u, resid=%d\n",
-		 __func__, off_dst, scsi_bufflen(scp), act_len, sdb->resid);
+		 __func__, off_dst, scsi_bufflen(scp), act_len,
+		 scsi_get_resid(scp));
 	n = (int)scsi_bufflen(scp) - ((int)off_dst + act_len);
-	sdb->resid = min(sdb->resid, n);
+	scsi_set_resid(scp, min(scsi_get_resid(scp), n));
 	return 0;
 }
 
@@ -2767,7 +2768,7 @@  static int resp_read_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)
 	if (unlikely(ret == -1))
 		return DID_ERROR << 16;
 
-	scp->sdb.resid = scsi_bufflen(scp) - ret;
+	scsi_set_resid(scp, scsi_bufflen(scp) - ret);
 
 	if (unlikely(sqcp)) {
 		if (sqcp->inj_recovered) {