From 5e2ee01d158c300a819e6f7ab12fd15cfd09a9c9 Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Tue, 29 Jul 2008 11:58:06 -0400 Subject: [PATCH] --- yaml --- r: 108427 b: refs/heads/master c: 59f4ff2ecff4cef36378928cec891785b402e80c h: refs/heads/master i: 108425: cfdb2ac39ce6635956da944a8e3fed6d5f5be999 108423: be54a76e736968787a055aa86e57e27a41d38733 v: v3 --- [refs] | 2 +- trunk/drivers/usb/storage/transport.c | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/[refs] b/[refs] index ace5d6eb76a9..c8b2c7401e3a 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 1a21175a615ed346e8043f5e9d60a672266b84b4 +refs/heads/master: 59f4ff2ecff4cef36378928cec891785b402e80c diff --git a/trunk/drivers/usb/storage/transport.c b/trunk/drivers/usb/storage/transport.c index fcbbfdb7b2b0..3523a0bfa0ff 100644 --- a/trunk/drivers/usb/storage/transport.c +++ b/trunk/drivers/usb/storage/transport.c @@ -1032,8 +1032,21 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us) /* try to compute the actual residue, based on how much data * was really transferred and what the device tells us */ - if (residue) { - if (!(us->fflags & US_FL_IGNORE_RESIDUE)) { + if (residue && !(us->fflags & US_FL_IGNORE_RESIDUE)) { + + /* Heuristically detect devices that generate bogus residues + * by seeing what happens with INQUIRY and READ CAPACITY + * commands. + */ + if (bcs->Status == US_BULK_STAT_OK && + scsi_get_resid(srb) == 0 && + ((srb->cmnd[0] == INQUIRY && + transfer_length == 36) || + (srb->cmnd[0] == READ_CAPACITY && + transfer_length == 8))) { + us->fflags |= US_FL_IGNORE_RESIDUE; + + } else { residue = min(residue, transfer_length); scsi_set_resid(srb, max(scsi_get_resid(srb), (int) residue));