Commit 0ab5aead authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman

[PATCH] USB storage: Update scatter-gather handling in the shuttle-usbat

This patch updates the shuttle_usbat driver to use the new scatter-gather
transfer routines.  The small set of changes needed speaks well for the
original organization of the code.

This has not been tested.
parent 5151c536
......@@ -40,7 +40,6 @@
*/
#include "transport.h"
#include "raw_bulk.h"
#include "protocol.h"
#include "usb.h"
#include "debug.h"
......@@ -529,9 +528,8 @@ int usbat_handle_read10(struct us_data *us,
unsigned char *buffer;
unsigned int len;
unsigned int sector;
struct scatterlist *sg = NULL;
int sg_segment = 0;
int sg_offset = 0;
unsigned int sg_segment = 0;
unsigned int sg_offset = 0;
US_DEBUGP("handle_read10: transfersize %d\n",
srb->transfersize);
......@@ -572,19 +570,20 @@ int usbat_handle_read10(struct us_data *us,
len = (65535/srb->transfersize) * srb->transfersize;
US_DEBUGP("Max read is %d bytes\n", len);
buffer = kmalloc(len, GFP_NOIO);
if (buffer == NULL) // bloody hell!
return USB_STOR_TRANSPORT_FAILED;
len = min(len, srb->request_bufflen);
if (srb->use_sg) {
buffer = kmalloc(len, GFP_NOIO);
if (buffer == NULL) // bloody hell!
return USB_STOR_TRANSPORT_FAILED;
} else
buffer = srb->request_buffer;
sector = short_pack(data[7+3], data[7+2]);
sector <<= 16;
sector |= short_pack(data[7+5], data[7+4]);
transferred = 0;
if (srb->use_sg) {
sg = (struct scatterlist *)srb->request_buffer;
sg_segment = 0; // for keeping track of where we are in
sg_offset = 0; // the scatter/gather list
}
sg_segment = 0; // for keeping track of where we are in
sg_offset = 0; // the scatter/gather list
while (transferred != srb->request_bufflen) {
......@@ -618,10 +617,10 @@ int usbat_handle_read10(struct us_data *us,
// Transfer the received data into the srb buffer
if (srb->use_sg)
us_copy_to_sgbuf(buffer, len, sg,
&sg_segment, &sg_offset, srb->use_sg);
usb_stor_access_xfer_buf(buffer, len, srb,
&sg_segment, &sg_offset, TO_XFER_BUF);
else
memcpy(srb->request_buffer+transferred, buffer, len);
buffer += len;
// Update the amount transferred and the sector number
......@@ -630,7 +629,8 @@ int usbat_handle_read10(struct us_data *us,
} // while transferred != srb->request_bufflen
kfree(buffer);
if (srb->use_sg)
kfree(buffer);
return result;
}
......
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