You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
992 if (transfer_length) {<br />
993 unsigned int pipe = srb->sc_data_direction ==<br />
DMA_FROM_DEVICE ?<br />
994 us->recv_bulk_pipe : us->send_bulk_pipe;<br />
995 result = usb_stor_bulk_transfer_sg(us, pipe,<br />
996 srb->request_buffer, transfer_length,<br />
997 srb->use_sg, &srb->resid);<br />
998 US_DEBUGP("Bulk data transfer result 0x%x\n", result);<br />
999 if (result == USB_STOR_XFER_ERROR)<br />
1000 return USB_STOR_TRANSPORT_ERROR;<br />
1001<br />
1002 /* If the device tried to send back more data than the<br />
1003 * amount requested, the spec requires us to transfer<br />
1004 * the CSW anyway. Since there's no point retrying the<br />
1005 * the command, we'll return fake sense data indicating<br />
1006 * Illegal Request, Invalid Field in CDB.<br />
1007 */<br />
1008 if (result == USB_STOR_XFER_LONG)<br />
1009 fake_sense = 1;<br />
152<br />
1010 }<br />
1011<br />
1012 /* See flow chart on pg 15 <strong>of</strong> the Bulk Only Transport spec for<br />
1013 * an explanation <strong>of</strong> how this code works.<br />
1014 */<br />
1015<br />
1016 /* get CSW for device status */<br />
1017 US_DEBUGP("Attempting to get CSW...\n");<br />
1018 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,<br />
1019 bcs, US_BULK_CS_WRAP_LEN, &cswlen);<br />
1020<br />
1021 /* Some broken devices add unnecessary zero-length packets to the<br />
1022 * end <strong>of</strong> their data transfers. Such packets show up as 0-length<br />
1023 * CSWs. If we encounter such a thing, try to read the CSW again.<br />
1024 */<br />
1025 if (result == USB_STOR_XFER_SHORT && cswlen == 0) {<br />
1026 US_DEBUGP("Received 0-length CSW; retrying...\n");<br />
1027 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,<br />
1028 bcs, US_BULK_CS_WRAP_LEN, &cswlen);<br />
1029 }<br />
1030<br />
1031 /* did the attempt to read the CSW fail? */<br />
1032 if (result == USB_STOR_XFER_STALLED) {<br />
1033