ChangeSet 1.1760.26.16, 2004/06/24 11:16:26-07:00, mdharm-usb@one-eyed-alien.net [PATCH] USB: Patch to signal underflow in usb-storage driver This patch causes the usb-storage driver to return an error indication (DID_ERROR together with SUGGEST_RETRY) when the amount transferred by a SCSI command is smaller than the "underflow" amount. Some devices, like the iRiver H100 series, occasionally transfer 0 bytes with GOOD status. This change will make the sd driver aware that something unexpected has happened so it can retry the command. Signed-off-by: Alan Stern Signed-off-by: Matthew Dharm Signed-off-by: Greg Kroah-Hartman drivers/usb/storage/transport.c | 6 ++++++ 1 files changed, 6 insertions(+) diff -Nru a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c --- a/drivers/usb/storage/transport.c 2004-06-29 16:25:33 -07:00 +++ b/drivers/usb/storage/transport.c 2004-06-29 16:25:33 -07:00 @@ -708,6 +708,12 @@ srb->sense_buffer[0] = 0x0; } } + + /* Did we transfer less than the minimum amount required? */ + if (srb->result == SAM_STAT_GOOD && + srb->request_bufflen - srb->resid < srb->underflow) + srb->result = (DID_ERROR << 16) | (SUGGEST_RETRY << 24); + return; /* abort processing: the bulk-only transport requires a reset