ChangeSet 1.1504.2.24, 2003/12/09 11:44:56-08:00, [EMAIL PROTECTED] [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. drivers/usb/storage/shuttle_usbat.c | 32 ++++++++++++++++---------------- 1 files changed, 16 insertions(+), 16 deletions(-) diff -Nru a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c --- a/drivers/usb/storage/shuttle_usbat.c Mon Dec 29 14:24:19 2003 +++ b/drivers/usb/storage/shuttle_usbat.c Mon Dec 29 14:24:19 2003 @@ -40,7 +40,6 @@ */ #include "transport.h" -#include "raw_bulk.h" #include "protocol.h" #include "usb.h" #include "debug.h" @@ -529,9 +528,8 @@ 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 @@ 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 @@ // 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 @@ } // while transferred != srb->request_bufflen - kfree(buffer); + if (srb->use_sg) + kfree(buffer); return result; } ------------------------------------------------------- This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id78&alloc_id371&op=click _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel