X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fscsi%2Fscsi.c;h=36c92f961e154fb46b94690b36dd09d624e59666;hb=8a0ca91e1db5de5eb5b18cfa919d52ff8be375af;hp=110e776d1a078cbd24cfdb795f7fec16cf95f1c3;hpb=d626e3bf728c47746f2129aa00c775d4e8c2a73b;p=linux-2.6 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 110e776d1a..36c92f961e 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -855,9 +855,18 @@ void scsi_finish_command(struct scsi_cmnd *cmd) good_bytes = scsi_bufflen(cmd); if (cmd->request->cmd_type != REQ_TYPE_BLOCK_PC) { + int old_good_bytes = good_bytes; drv = scsi_cmd_to_driver(cmd); if (drv->done) good_bytes = drv->done(cmd); + /* + * USB may not give sense identifying bad sector and + * simply return a residue instead, so subtract off the + * residue if drv->done() error processing indicates no + * change to the completion length. + */ + if (good_bytes == old_good_bytes) + good_bytes -= scsi_get_resid(cmd); } scsi_io_completion(cmd, good_bytes); }