All of lore.kernel.org
 help / color / mirror / Atom feed
* [v2,7/7] Move the resid member from struct scsi_data_buffer into struct scsi_cmnd
@ 2019-01-23 19:10 Bart Van Assche
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Van Assche @ 2019-01-23 19:10 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Bart Van Assche, Oliver Neukum, Douglas Gilbert,
	Hannes Reinecke, Christoph Hellwig, linux-usb

This patch does not change any functionality but reduces the size of
struct scsi_cmnd.

Cc: Oliver Neukum <oneukum@suse.com>
Cc: Douglas Gilbert <dgilbert@interlog.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: linux-usb@vger.kernel.org
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/scsi_lib.c   | 2 --
 drivers/usb/storage/uas.c | 8 +++++---
 include/scsi/scsi_cmnd.h  | 9 ++++-----
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index bcbf266e4172..4feba3b5aff1 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -945,14 +945,12 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
 		 * scsi_result_to_blk_status may have reset the host_byte
 		 */
 		scsi_req(req)->result = cmd->result;
-		scsi_req(req)->resid_len = scsi_get_resid(cmd);
 
 		if (unlikely(scsi_bidi_cmnd(cmd))) {
 			/*
 			 * Bidi commands Must be complete as a whole,
 			 * both sides at once.
 			 */
-			scsi_req(req->next_rq)->resid_len = scsi_in(cmd)->resid;
 			if (scsi_end_request(req, BLK_STS_OK, blk_rq_bytes(req),
 					blk_rq_bytes(req->next_rq)))
 				WARN_ONCE(true,
diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
index 36742e8e7edc..ea40fd78e6ff 100644
--- a/drivers/usb/storage/uas.c
+++ b/drivers/usb/storage/uas.c
@@ -365,7 +365,7 @@ static void uas_stat_cmplt(struct urb *urb)
 
 static void uas_data_cmplt(struct urb *urb)
 {
-	struct scsi_cmnd *cmnd = urb->context;
+	struct scsi_cmnd *cmnd = urb->context, *cmpl_cmd = NULL;
 	struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp;
 	struct uas_dev_info *devinfo = (void *)cmnd->device->hostdata;
 	struct scsi_data_buffer *sdb = NULL;
@@ -375,10 +375,12 @@ static void uas_data_cmplt(struct urb *urb)
 	spin_lock_irqsave(&devinfo->lock, flags);
 
 	if (cmdinfo->data_in_urb == urb) {
+		cmpl_cmd = scsi_in_cmd(cmnd);
 		sdb = scsi_in(cmnd);
 		cmdinfo->state &= ~DATA_IN_URB_INFLIGHT;
 		cmdinfo->data_in_urb = NULL;
 	} else if (cmdinfo->data_out_urb == urb) {
+		cmpl_cmd = scsi_out_cmd(cmnd);
 		sdb = scsi_out(cmnd);
 		cmdinfo->state &= ~DATA_OUT_URB_INFLIGHT;
 		cmdinfo->data_out_urb = NULL;
@@ -401,9 +403,9 @@ static void uas_data_cmplt(struct urb *urb)
 		if (status != -ENOENT && status != -ECONNRESET && status != -ESHUTDOWN)
 			uas_log_cmd_state(cmnd, "data cmplt err", status);
 		/* error: no data transfered */
-		sdb->resid = sdb->length;
+		cmpl_cmd->req.resid_len = sdb->length;
 	} else {
-		sdb->resid = sdb->length - urb->actual_length;
+		cmpl_cmd->req.resid_len = sdb->length - urb->actual_length;
 	}
 	uas_try_complete(cmnd, __func__);
 out:
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index 8f3ed55a5ee5..9035c760cae0 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -35,7 +35,6 @@ struct scsi_driver;
 struct scsi_data_buffer {
 	struct sg_table table;
 	unsigned length;
-	int resid;
 };
 
 /* embedded in scsi_cmnd */
@@ -229,22 +228,22 @@ static inline unsigned scsi_bufflen(struct scsi_cmnd *cmd)
 
 static inline void scsi_in_set_resid(struct scsi_cmnd *cmd, int resid)
 {
-	scsi_in_cmd(cmd)->sdb.resid = resid;
+	scsi_in_cmd(cmd)->req.resid_len = resid;
 }
 
 static inline int scsi_in_get_resid(struct scsi_cmnd *cmd)
 {
-	return scsi_in_cmd(cmd)->sdb.resid;
+	return scsi_in_cmd(cmd)->req.resid_len;
 }
 
 static inline void scsi_out_set_resid(struct scsi_cmnd *cmd, int resid)
 {
-	cmd->sdb.resid = resid;
+	cmd->req.resid_len = resid;
 }
 
 static inline int scsi_out_get_resid(struct scsi_cmnd *cmd)
 {
-	return cmd->sdb.resid;
+	return cmd->req.resid_len;
 }
 
 static inline void scsi_set_resid(struct scsi_cmnd *cmd, int resid)

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [v2,7/7] Move the resid member from struct scsi_data_buffer into struct scsi_cmnd
@ 2019-01-29  8:37 Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2019-01-29  8:37 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K . Petersen, James E . J . Bottomley, linux-scsi,
	Oliver Neukum, Douglas Gilbert, Hannes Reinecke,
	Christoph Hellwig, linux-usb

On Wed, Jan 23, 2019 at 11:10:13AM -0800, Bart Van Assche wrote:
> This patch does not change any functionality but reduces the size of
> struct scsi_cmnd.

This looks sensible, but please do it without adding more pointless
wrappers first, just use the field directly.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-01-29  8:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-23 19:10 [v2,7/7] Move the resid member from struct scsi_data_buffer into struct scsi_cmnd Bart Van Assche
2019-01-29  8:37 Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.