From 87bfae898735fea21f213d91e5972e2f3cd210a2 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Fri, 27 Aug 2010 17:33:54 +0000 Subject: [PATCH] A floppy drive is a slow device, so we have to try many times before getting a result. This gets read capaity working, the device shows up in drivesetup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38404 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/drivers/disk/usb/usb_floppy/usb_disk.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/add-ons/kernel/drivers/disk/usb/usb_floppy/usb_disk.cpp b/src/add-ons/kernel/drivers/disk/usb/usb_floppy/usb_disk.cpp index 0c309ad2a4..b0ebd6458f 100644 --- a/src/add-ons/kernel/drivers/disk/usb/usb_floppy/usb_disk.cpp +++ b/src/add-ons/kernel/drivers/disk/usb/usb_floppy/usb_disk.cpp @@ -261,6 +261,11 @@ usb_disk_operation(device_lun *lun, uint8* operation, if (result != B_OK || actualLength != 12) { TRACE("Command stage: wrote %ld bytes (error: %s)\n", actualLength, strerror(result)); + + // There was an error, we have to do a request sense to reset the device + if (operation[0] != SCSI_REQUEST_SENSE_6) { + result = usb_disk_request_sense(lun); + } return B_ERROR; } @@ -544,12 +549,11 @@ usb_disk_update_capacity(device_lun *lun) // changed, which is more or less expected if it is the first operation // on the device or the device only clears the unit atention for capacity // reads. - for (int32 i = 0; i < 3; i++) { + do { + snooze(10000); result = usb_disk_operation(lun, commandBlock, ¶meter, &dataLength, true); - if (result == B_OK) - break; - } + } while (result != B_OK); if (result != B_OK) { TRACE_ALWAYS("failed to update capacity\n");