Commit dd829d23 authored by Boaz Harrosh's avatar Boaz Harrosh Committed by James Bottomley

[SCSI] usb: protocol - convert to accessors and !use_sg code path removal

 - Use scsi data accessors and remove of !use_sg code path
Signed-off-by: default avatarBoaz Harrosh <bharrosh@panasas.com>
Acked-by: default avatarMatthew Dharm <mdharm-scsi@one-eyed-alien.net>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@HansenPartnership.com>
parent caa1e8c3
...@@ -149,11 +149,7 @@ void usb_stor_transparent_scsi_command(struct scsi_cmnd *srb, ...@@ -149,11 +149,7 @@ void usb_stor_transparent_scsi_command(struct scsi_cmnd *srb,
***********************************************************************/ ***********************************************************************/
/* Copy a buffer of length buflen to/from the srb's transfer buffer. /* Copy a buffer of length buflen to/from the srb's transfer buffer.
* (Note: for scatter-gather transfers (srb->use_sg > 0), srb->request_buffer * Update the **sgptr and *offset variables so that the next copy will
* points to a list of s-g entries and we ignore srb->request_bufflen.
* For non-scatter-gather transfers, srb->request_buffer points to the
* transfer buffer itself and srb->request_bufflen is the buffer's length.)
* Update the *index and *offset variables so that the next copy will
* pick up from where this one left off. */ * pick up from where this one left off. */
unsigned int usb_stor_access_xfer_buf(unsigned char *buffer, unsigned int usb_stor_access_xfer_buf(unsigned char *buffer,
...@@ -162,37 +158,22 @@ unsigned int usb_stor_access_xfer_buf(unsigned char *buffer, ...@@ -162,37 +158,22 @@ unsigned int usb_stor_access_xfer_buf(unsigned char *buffer,
{ {
unsigned int cnt; unsigned int cnt;
/* If not using scatter-gather, just transfer the data directly. /* We have to go through the list one entry
* Make certain it will fit in the available buffer space. */
if (srb->use_sg == 0) {
if (*offset >= srb->request_bufflen)
return 0;
cnt = min(buflen, srb->request_bufflen - *offset);
if (dir == TO_XFER_BUF)
memcpy((unsigned char *) srb->request_buffer + *offset,
buffer, cnt);
else
memcpy(buffer, (unsigned char *) srb->request_buffer +
*offset, cnt);
*offset += cnt;
/* Using scatter-gather. We have to go through the list one entry
* at a time. Each s-g entry contains some number of pages, and * at a time. Each s-g entry contains some number of pages, and
* each page has to be kmap()'ed separately. If the page is already * each page has to be kmap()'ed separately. If the page is already
* in kernel-addressable memory then kmap() will return its address. * in kernel-addressable memory then kmap() will return its address.
* If the page is not directly accessible -- such as a user buffer * If the page is not directly accessible -- such as a user buffer
* located in high memory -- then kmap() will map it to a temporary * located in high memory -- then kmap() will map it to a temporary
* position in the kernel's virtual address space. */ * position in the kernel's virtual address space. */
} else {
struct scatterlist *sg = *sgptr; struct scatterlist *sg = *sgptr;
if (!sg) if (!sg)
sg = (struct scatterlist *) srb->request_buffer; sg = scsi_sglist(srb);
/* This loop handles a single s-g list entry, which may /* This loop handles a single s-g list entry, which may
* include multiple pages. Find the initial page structure * include multiple pages. Find the initial page structure
* and the starting offset within the page, and update * and the starting offset within the page, and update
* the *offset and *index values for the next loop. */ * the *offset and **sgptr values for the next loop. */
cnt = 0; cnt = 0;
while (cnt < buflen) { while (cnt < buflen) {
struct page *page = sg_page(sg) + struct page *page = sg_page(sg) +
...@@ -235,7 +216,6 @@ unsigned int usb_stor_access_xfer_buf(unsigned char *buffer, ...@@ -235,7 +216,6 @@ unsigned int usb_stor_access_xfer_buf(unsigned char *buffer,
} }
} }
*sgptr = sg; *sgptr = sg;
}
/* Return the amount actually transferred */ /* Return the amount actually transferred */
return cnt; return cnt;
...@@ -251,6 +231,6 @@ void usb_stor_set_xfer_buf(unsigned char *buffer, ...@@ -251,6 +231,6 @@ void usb_stor_set_xfer_buf(unsigned char *buffer,
usb_stor_access_xfer_buf(buffer, buflen, srb, &sg, &offset, usb_stor_access_xfer_buf(buffer, buflen, srb, &sg, &offset,
TO_XFER_BUF); TO_XFER_BUF);
if (buflen < srb->request_bufflen) if (buflen < scsi_bufflen(srb))
srb->resid = srb->request_bufflen - buflen; scsi_set_resid(srb, scsi_bufflen(srb) - buflen);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment