From 395346c411a08a22d5a7efcde929b58c4190784a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Tue, 28 Sep 2010 17:30:15 +0000 Subject: [PATCH] =?UTF-8?q?Patch=20by=20Matthias:=20The=20residue=20field?= =?UTF-8?q?=20is=20not=20maintained=20correctly=20by=20all=20USB=20devices?= =?UTF-8?q?,=20so=20calculate=20it=20instead.=20Gets=20some=20USB=20disk?= =?UTF-8?q?=20devices=20working=20like=20the=20SuperTOP.=20MacOS=20X=20is?= =?UTF-8?q?=20doing=20the=20same=20thing,=20as=20researched=20by=20J=C3=83?= =?UTF-8?q?=C2=A9r=C3=83=C2=B4me.=20Closes=20ticket=20#6604.=20Thanks!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38836 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../drivers/disk/usb/usb_disk/usb_disk.cpp | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/add-ons/kernel/drivers/disk/usb/usb_disk/usb_disk.cpp b/src/add-ons/kernel/drivers/disk/usb/usb_disk/usb_disk.cpp index ef7fdd9698..b3f5f259b3 100644 --- a/src/add-ons/kernel/drivers/disk/usb/usb_disk/usb_disk.cpp +++ b/src/add-ons/kernel/drivers/disk/usb/usb_disk/usb_disk.cpp @@ -362,16 +362,14 @@ usb_disk_operation(device_lun *lun, uint8 operation, uint8 opLength, switch (status.status) { case CSW_STATUS_COMMAND_PASSED: - case CSW_STATUS_COMMAND_FAILED: { - if (status.data_residue > command.data_transfer_length) { - // command status wrapper is not meaningful - TRACE_ALWAYS("command status wrapper has invalid residue\n"); - usb_disk_reset_recovery(device); - return B_ERROR; - } + case CSW_STATUS_COMMAND_FAILED: + { + // The residue from "status.data_residue" is not maintained + // correctly by some devices, so calculate it instead. + uint32 residue = command.data_transfer_length - transferedData; if (dataLength != NULL) { - *dataLength -= status.data_residue; + *dataLength -= residue; if (transferedData < *dataLength) { TRACE_ALWAYS("less data transfered than indicated\n"); *dataLength = transferedData; @@ -393,14 +391,16 @@ usb_disk_operation(device_lun *lun, uint8 operation, uint8 opLength, } } - case CSW_STATUS_PHASE_ERROR: { + case CSW_STATUS_PHASE_ERROR: + { // a protocol or device error occured TRACE_ALWAYS("phase error in operation 0x%02x\n", operation); usb_disk_reset_recovery(device); return B_ERROR; } - default: { + default: + { // command status wrapper is not meaningful TRACE_ALWAYS("command status wrapper has invalid status\n"); usb_disk_reset_recovery(device);