aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorFelipe Balbi <felipe.balbi@nokia.com>2008-09-18 19:00:02 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-10-17 17:40:56 -0400
commit549c41e0ac0a3eb68cfdaeb43c1a314e2a6c289a (patch)
tree91260dbbb282993e4f6dec1f17e9d716e778e701 /drivers
parent8296345a35551414b07419f4c9223734c1fc5437 (diff)
usb: gadget: workaround storage command size issues
Try to workaround issues with bad SCSI implementations by ignoring the command size error. Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com> Acked-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/gadget/file_storage.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index 0c632d22a631..e0f616f39ba0 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -2676,11 +2676,24 @@ static int check_command(struct fsg_dev *fsg, int cmnd_size,
2676 /* Verify the length of the command itself */ 2676 /* Verify the length of the command itself */
2677 if (cmnd_size != fsg->cmnd_size) { 2677 if (cmnd_size != fsg->cmnd_size) {
2678 2678
2679 /* Special case workaround: MS-Windows issues REQUEST SENSE 2679 /* Special case workaround: There are plenty of buggy SCSI
2680 * with cbw->Length == 12 (it should be 6). */ 2680 * implementations. Many have issues with cbw->Length
2681 if (fsg->cmnd[0] == SC_REQUEST_SENSE && fsg->cmnd_size == 12) 2681 * field passing a wrong command size. For those cases we
2682 * always try to work around the problem by using the length
2683 * sent by the host side provided it is at least as large
2684 * as the correct command length.
2685 * Examples of such cases would be MS-Windows, which issues
2686 * REQUEST SENSE with cbw->Length == 12 where it should
2687 * be 6, and xbox360 issuing INQUIRY, TEST UNIT READY and
2688 * REQUEST SENSE with cbw->Length == 10 where it should
2689 * be 6 as well.
2690 */
2691 if (cmnd_size <= fsg->cmnd_size) {
2692 DBG(fsg, "%s is buggy! Expected length %d "
2693 "but we got %d\n", name,
2694 cmnd_size, fsg->cmnd_size);
2682 cmnd_size = fsg->cmnd_size; 2695 cmnd_size = fsg->cmnd_size;
2683 else { 2696 } else {
2684 fsg->phase_error = 1; 2697 fsg->phase_error = 1;
2685 return -EINVAL; 2698 return -EINVAL;
2686 } 2699 }