ChangeSet 1.1504.2.22, 2003/12/09 11:43:14-08:00, [EMAIL PROTECTED]

[PATCH] USB storage: Another utility scatter-gather routine

This patch adds a small utility routine for storing data in a transfer
buffer.  The next patch uses this routine quite a bit in the isd200
driver.


 drivers/usb/storage/protocol.c |   13 +++++++++++++
 drivers/usb/storage/protocol.h |    2 ++
 drivers/usb/storage/usb.c      |    8 +-------
 3 files changed, 16 insertions(+), 7 deletions(-)


diff -Nru a/drivers/usb/storage/protocol.c b/drivers/usb/storage/protocol.c
--- a/drivers/usb/storage/protocol.c    Mon Dec 29 14:24:33 2003
+++ b/drivers/usb/storage/protocol.c    Mon Dec 29 14:24:33 2003
@@ -295,3 +295,16 @@
        }
        return cnt;
 }
+
+/* Store the contents of buffer into srb's transfer buffer and set the
+ * residue. */
+void usb_stor_set_xfer_buf(unsigned char *buffer,
+       unsigned int buflen, Scsi_Cmnd *srb)
+{
+       unsigned int index = 0, offset = 0;
+
+       usb_stor_access_xfer_buf(buffer, buflen, srb, &index, &offset,
+                       TO_XFER_BUF);
+       if (buflen < srb->request_bufflen)
+               srb->resid = srb->request_bufflen - buflen;
+}
diff -Nru a/drivers/usb/storage/protocol.h b/drivers/usb/storage/protocol.h
--- a/drivers/usb/storage/protocol.h    Mon Dec 29 14:24:33 2003
+++ b/drivers/usb/storage/protocol.h    Mon Dec 29 14:24:33 2003
@@ -72,4 +72,6 @@
        unsigned int buflen, Scsi_Cmnd *srb, unsigned int *index,
        unsigned int *offset, enum xfer_buf_dir dir);
 
+extern void usb_stor_set_xfer_buf(unsigned char *buffer,
+       unsigned int buflen, Scsi_Cmnd *srb);
 #endif
diff -Nru a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
--- a/drivers/usb/storage/usb.c Mon Dec 29 14:24:33 2003
+++ b/drivers/usb/storage/usb.c Mon Dec 29 14:24:33 2003
@@ -236,8 +236,6 @@
 void fill_inquiry_response(struct us_data *us, unsigned char *data,
                unsigned int data_len)
 {
-       unsigned int index, offset;
-
        if (data_len<36) // You lose.
                return;
 
@@ -264,11 +262,7 @@
                data[35] = 0x30 + ((us->pusb_dev->descriptor.bcdDevice) & 0x0F);
        }
 
-       index = offset = 0;
-       usb_stor_access_xfer_buf(data, data_len, us->srb,
-                       &index, &offset, TO_XFER_BUF);
-       if (data_len < us->srb->request_bufflen)
-               us->srb->resid = us->srb->request_bufflen - data_len;
+       usb_stor_set_xfer_buf(data, data_len, us->srb);
 }
 
 static int usb_stor_control_thread(void * __us)



-------------------------------------------------------
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

Reply via email to