From 4ad0015d569f3cb860c0a6a282185a84056195dc Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Tue, 1 Apr 2008 20:43:45 +0000 Subject: [PATCH] * Retry some times when the device reports it is not ready * Use the CBW_SIGNATURE define instead of the numeric value git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24729 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/drivers/disk/usb/usb_disk/usb_disk.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 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 3b95120d3e..24dd1e5545 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 @@ -157,7 +157,7 @@ usb_disk_operation(disk_device *device, uint8 operation, uint8 opLength, uint32 *dataLength, bool directionIn) { command_block_wrapper command; - command.signature = 0x43425355; + command.signature = CBW_SIGNATURE; command.tag = device->current_tag++; command.data_transfer_length = (dataLength != NULL ? *dataLength : 0); command.flags = (directionIn ? CBW_DATA_INPUT : CBW_DATA_OUTPUT); @@ -500,7 +500,12 @@ usb_disk_device_added(usb_device newDevice, void **cookie) } result = usb_disk_inquiry(device); - usb_disk_test_unit_ready(device); + for (uint32 tries = 0; tries < 3; tries++) { + if (usb_disk_test_unit_ready(device) == B_OK) + break; + snooze(10000); + } + if (result != B_OK || usb_disk_update_capacity(device) != B_OK) { TRACE_ALWAYS("failed to read device data\n"); delete_sem(device->notify);