Commit 2505f3df authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman

[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.
parent 313b9054
...@@ -295,3 +295,16 @@ unsigned int usb_stor_access_xfer_buf(unsigned char *buffer, ...@@ -295,3 +295,16 @@ unsigned int usb_stor_access_xfer_buf(unsigned char *buffer,
} }
return cnt; 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;
}
...@@ -72,4 +72,6 @@ extern unsigned int usb_stor_access_xfer_buf(unsigned char *buffer, ...@@ -72,4 +72,6 @@ extern unsigned int usb_stor_access_xfer_buf(unsigned char *buffer,
unsigned int buflen, Scsi_Cmnd *srb, unsigned int *index, unsigned int buflen, Scsi_Cmnd *srb, unsigned int *index,
unsigned int *offset, enum xfer_buf_dir dir); 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 #endif
...@@ -236,8 +236,6 @@ struct usb_driver usb_storage_driver = { ...@@ -236,8 +236,6 @@ struct usb_driver usb_storage_driver = {
void fill_inquiry_response(struct us_data *us, unsigned char *data, void fill_inquiry_response(struct us_data *us, unsigned char *data,
unsigned int data_len) unsigned int data_len)
{ {
unsigned int index, offset;
if (data_len<36) // You lose. if (data_len<36) // You lose.
return; return;
...@@ -264,11 +262,7 @@ void fill_inquiry_response(struct us_data *us, unsigned char *data, ...@@ -264,11 +262,7 @@ void fill_inquiry_response(struct us_data *us, unsigned char *data,
data[35] = 0x30 + ((us->pusb_dev->descriptor.bcdDevice) & 0x0F); data[35] = 0x30 + ((us->pusb_dev->descriptor.bcdDevice) & 0x0F);
} }
index = offset = 0; usb_stor_set_xfer_buf(data, data_len, us->srb);
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;
} }
static int usb_stor_control_thread(void * __us) static int usb_stor_control_thread(void * __us)
......
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