From: Boaz Harrosh <bharrosh@panasas.com>
To: James Bottomley <James.Bottomley@SteelEye.com>,
Jens Axboe <jens.axboe@oracle.com>,
FUJITA Tomonori <tomof@acm.org>, Matthew Wilcox <matthew@wil.cx>,
Matthew Dharm <mdharm-scsi@one-e>
Cc: Benny Halevy <bhalevy@panasas.com>, Pete Wyckoff <pw@osc.edu>
Subject: [PATCH 3/32] usb: transport - convert to accessors and !use_sg code path removal
Date: Wed, 17 Oct 2007 19:26:15 +0200 [thread overview]
Message-ID: <471645B7.1050207@panasas.com> (raw)
In-Reply-To: <47164306.6090702@panasas.com>
- Use scsi data accessors and remove of !use_sg code path.
- New usb_stor_bulk_srb() for use by drivers
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
---
drivers/usb/storage/transport.c | 44 +++++++++++++++++++++++---------------
drivers/usb/storage/transport.h | 2 +
2 files changed, 29 insertions(+), 17 deletions(-)
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index c646750..d3a84a2 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -459,6 +459,21 @@ static int usb_stor_bulk_transfer_sglist(struct us_data *us, unsigned int pipe,
}
/*
+ * Common used function. Transfer a complete command
+ * via usb_stor_bulk_transfer_sglist() above. Set cmnd resid
+ */
+int usb_stor_bulk_srb(struct us_data* us, unsigned int pipe,
+ struct scsi_cmnd* srb)
+{
+ int resid = scsi_get_resid(srb);
+ int result = usb_stor_bulk_transfer_sglist(us, pipe, scsi_sglist(srb),
+ scsi_sg_count(srb), scsi_bufflen(srb),
+ &resid);
+ scsi_set_resid(srb, resid);
+ return result;
+}
+
+/*
* Transfer an entire SCSI command's worth of data payload over the bulk
* pipe.
*
@@ -508,7 +523,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
int result;
/* send the command to the transport layer */
- srb->resid = 0;
+ scsi_set_resid(srb, 0);
result = us->transport(srb, us);
/* if the command gets aborted by the higher layers, we need to
@@ -568,7 +583,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
* A short transfer on a command where we don't expect it
* is unusual, but it doesn't mean we need to auto-sense.
*/
- if ((srb->resid > 0) &&
+ if ((scsi_get_resid(srb) > 0) &&
!((srb->cmnd[0] == REQUEST_SENSE) ||
(srb->cmnd[0] == INQUIRY) ||
(srb->cmnd[0] == MODE_SENSE) ||
@@ -593,7 +608,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
srb->cmd_len = 12;
/* issue the auto-sense command */
- srb->resid = 0;
+ scsi_set_resid(srb, 0);
temp_result = us->transport(us->srb, us);
/* let's clean up right away */
@@ -649,7 +664,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
/* Did we transfer less than the minimum amount required? */
if (srb->result == SAM_STAT_GOOD &&
- srb->request_bufflen - srb->resid < srb->underflow)
+ scsi_bufflen(srb) - scsi_get_resid(srb) < srb->underflow)
srb->result = (DID_ERROR << 16) | (SUGGEST_RETRY << 24);
return;
@@ -708,7 +723,7 @@ void usb_stor_stop_transport(struct us_data *us)
int usb_stor_CBI_transport(struct scsi_cmnd *srb, struct us_data *us)
{
- unsigned int transfer_length = srb->request_bufflen;
+ unsigned int transfer_length = scsi_bufflen(srb);
unsigned int pipe = 0;
int result;
@@ -737,9 +752,7 @@ int usb_stor_CBI_transport(struct scsi_cmnd *srb, struct us_data *us)
if (transfer_length) {
pipe = srb->sc_data_direction == DMA_FROM_DEVICE ?
us->recv_bulk_pipe : us->send_bulk_pipe;
- result = usb_stor_bulk_transfer_sg(us, pipe,
- srb->request_buffer, transfer_length,
- srb->use_sg, &srb->resid);
+ result = usb_stor_bulk_srb(us, pipe, srb);
US_DEBUGP("CBI data stage result is 0x%x\n", result);
/* if we stalled the data transfer it means command failed */
@@ -808,7 +821,7 @@ int usb_stor_CBI_transport(struct scsi_cmnd *srb, struct us_data *us)
*/
int usb_stor_CB_transport(struct scsi_cmnd *srb, struct us_data *us)
{
- unsigned int transfer_length = srb->request_bufflen;
+ unsigned int transfer_length = scsi_bufflen(srb);
int result;
/* COMMAND STAGE */
@@ -836,9 +849,7 @@ int usb_stor_CB_transport(struct scsi_cmnd *srb, struct us_data *us)
if (transfer_length) {
unsigned int pipe = srb->sc_data_direction == DMA_FROM_DEVICE ?
us->recv_bulk_pipe : us->send_bulk_pipe;
- result = usb_stor_bulk_transfer_sg(us, pipe,
- srb->request_buffer, transfer_length,
- srb->use_sg, &srb->resid);
+ result = usb_stor_bulk_srb(us, pipe, srb);
US_DEBUGP("CB data stage result is 0x%x\n", result);
/* if we stalled the data transfer it means command failed */
@@ -904,7 +915,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
{
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
struct bulk_cs_wrap *bcs = (struct bulk_cs_wrap *) us->iobuf;
- unsigned int transfer_length = srb->request_bufflen;
+ unsigned int transfer_length = scsi_bufflen(srb);
unsigned int residue;
int result;
int fake_sense = 0;
@@ -955,9 +966,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
if (transfer_length) {
unsigned int pipe = srb->sc_data_direction == DMA_FROM_DEVICE ?
us->recv_bulk_pipe : us->send_bulk_pipe;
- result = usb_stor_bulk_transfer_sg(us, pipe,
- srb->request_buffer, transfer_length,
- srb->use_sg, &srb->resid);
+ result = usb_stor_bulk_srb(us, pipe, srb);
US_DEBUGP("Bulk data transfer result 0x%x\n", result);
if (result == USB_STOR_XFER_ERROR)
return USB_STOR_TRANSPORT_ERROR;
@@ -1036,7 +1045,8 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
if (residue) {
if (!(us->flags & US_FL_IGNORE_RESIDUE)) {
residue = min(residue, transfer_length);
- srb->resid = max(srb->resid, (int) residue);
+ scsi_set_resid(srb, max(scsi_get_resid(srb),
+ (int) residue));
}
}
diff --git a/drivers/usb/storage/transport.h b/drivers/usb/storage/transport.h
index 633a715..ada7c2f 100644
--- a/drivers/usb/storage/transport.h
+++ b/drivers/usb/storage/transport.h
@@ -139,6 +139,8 @@ extern int usb_stor_bulk_transfer_buf(struct us_data *us, unsigned int pipe,
void *buf, unsigned int length, unsigned int *act_len);
extern int usb_stor_bulk_transfer_sg(struct us_data *us, unsigned int pipe,
void *buf, unsigned int length, int use_sg, int *residual);
+extern int usb_stor_bulk_srb(struct us_data* us, unsigned int pipe,
+ struct scsi_cmnd* srb);
extern int usb_stor_port_reset(struct us_data *us);
#endif
--
1.5.3.1
next prev parent reply other threads:[~2007-10-17 17:27 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-17 17:14 [patchset 0/33] scsi_data_buffer for after the last driver is converted Boaz Harrosh
2007-10-17 17:19 ` [PATCH 1/32] arm: fas216 Use scsi_eh API for REQUEST_SENSE invocation Boaz Harrosh
2007-10-17 17:22 ` [PATCH 2/32] isd200.c: use one-element sg list in issuing commands Boaz Harrosh
2007-10-17 17:26 ` Boaz Harrosh [this message]
2007-10-17 17:29 ` [PATCH 4/32] usb: protocol.c - convert to accessors and !use_sg code path removal Boaz Harrosh
2007-10-17 17:32 ` [PATCH 5/32] usb: shuttle_usbat.c " Boaz Harrosh
2007-10-17 17:34 ` [PATCH 6/32] usb: freecom.c & sddr09.c - convert to accessors and !use_sg cleanup Boaz Harrosh
2007-10-17 17:37 ` [PATCH 7/32] NCR5380 familly convert to accessors & " Boaz Harrosh
2007-10-17 17:41 ` [PATCH 8/32] arm: scsi convert to accessors and " Boaz Harrosh
2007-10-17 17:43 ` [PATCH 9/32] nsp_cs.c convert to data " Boaz Harrosh
2007-10-17 17:45 ` [PATCH 10/32] eata_pio.c: convert to " Boaz Harrosh
2007-10-17 17:47 ` [PATCH 11/32] a2091.c: " Boaz Harrosh
2007-10-17 17:50 ` [PATCH 12/32] a3000.c: " Boaz Harrosh
2007-10-17 17:53 ` [PATCH 13/32] aha1542.c: " Boaz Harrosh
2007-11-10 2:30 ` Randy Dunlap
2007-11-10 2:32 ` Randy Dunlap
2007-10-17 17:55 ` [PATCH 14/32] atp870u.c: " Boaz Harrosh
2007-10-17 17:57 ` [PATCH 15/32] fd_mcs.c: " Boaz Harrosh
2007-10-17 17:59 ` [PATCH 16/32] imm.c: " Boaz Harrosh
2007-10-17 18:00 ` [PATCH 17/32] ppa.c: " Boaz Harrosh
2007-10-17 18:03 ` [PATCH 18/32] wd33c93.c: " Boaz Harrosh
2007-10-17 18:04 ` [PATCH 19/32] qlogicpti.c: " Boaz Harrosh
2007-10-17 18:05 ` [PATCH 20/32] in2000.c: " Boaz Harrosh
2007-10-17 18:07 ` [PATCH 21/32] qla1280: convert to use the data buffer accessors Boaz Harrosh
2007-10-17 18:10 ` [PATCH 22/32] qla1280: Indentation fix Boaz Harrosh
2007-10-17 22:15 ` Matthew Wilcox
2007-10-18 16:32 ` [PATCH 22/32 ver2] " Boaz Harrosh
2007-10-17 18:12 ` [PATCH 23/32] scsi_debug: convert to use the data buffer accessors Boaz Harrosh
2007-10-17 18:15 ` [PATCH 24/32] wd7000.c - proper fix for boards without sg support Boaz Harrosh
2007-10-17 18:17 ` [PATCH 25/32] Remove psi240i driver from kernel Boaz Harrosh
2007-10-17 18:18 ` [PATCH 26/32] Remove of seagate.c driver Boaz Harrosh
2007-10-17 18:21 ` [PATCH 27/32] scsi_data_buffer Boaz Harrosh
2007-10-17 23:40 ` FUJITA Tomonori
2007-10-18 7:51 ` Boaz Harrosh
2007-10-18 7:57 ` FUJITA Tomonori
2007-10-18 8:27 ` Boaz Harrosh
2007-10-18 8:45 ` FUJITA Tomonori
2007-10-18 9:17 ` FUJITA Tomonori
2007-10-18 0:47 ` Matthew Wilcox
2007-10-18 6:59 ` Benny Halevy
2007-10-18 8:06 ` Matthew Wilcox
2007-10-18 8:31 ` Benny Halevy
2007-10-18 8:16 ` Boaz Harrosh
2007-10-18 8:54 ` Matthew Wilcox
2007-10-18 10:21 ` Boaz Harrosh
2007-10-18 14:26 ` Alan Stern
2007-10-18 15:44 ` Matthew Wilcox
2007-10-17 18:23 ` [PATCH 28/32] scsi_data_buffer - scsi_error.c Boaz Harrosh
2007-10-17 18:25 ` [PATCH 29/32] scsi_data_buffer - sd.c and sr.c Boaz Harrosh
2007-10-17 18:28 ` [PATCH 30/32] tgt: convert to use scsi_data_buffer Boaz Harrosh
2007-10-17 18:30 ` [PATCH 31/32] tgt: convert ibmvstgt and libsrp " Boaz Harrosh
2007-10-17 18:32 ` [PATCH 32/32] isd200.c - use of scsi_data_buffer Boaz Harrosh
2007-10-17 23:32 ` [patchset 0/33] scsi_data_buffer for after the last driver is converted FUJITA Tomonori
2007-10-18 7:44 ` [PATCH 33/33] Remove Compatibility mode hack from scsi_cmnd Boaz Harrosh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=471645B7.1050207@panasas.com \
--to=bharrosh@panasas.com \
--cc=James.Bottomley@SteelEye.com \
--cc=bhalevy@panasas.com \
--cc=jens.axboe@oracle.com \
--cc=matthew@wil.cx \
--cc=mdharm-scsi@one-e \
--cc=pw@osc.edu \
--cc=tomof@acm.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).