* 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
This commit is contained in:
Michael Lotz 2008-04-01 20:43:45 +00:00
parent 111522f174
commit 4ad0015d56
1 changed files with 7 additions and 2 deletions

View File

@ -157,7 +157,7 @@ usb_disk_operation(disk_device *device, uint8 operation, uint8 opLength,
uint32 *dataLength, bool directionIn) uint32 *dataLength, bool directionIn)
{ {
command_block_wrapper command; command_block_wrapper command;
command.signature = 0x43425355; command.signature = CBW_SIGNATURE;
command.tag = device->current_tag++; command.tag = device->current_tag++;
command.data_transfer_length = (dataLength != NULL ? *dataLength : 0); command.data_transfer_length = (dataLength != NULL ? *dataLength : 0);
command.flags = (directionIn ? CBW_DATA_INPUT : CBW_DATA_OUTPUT); 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); 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) { if (result != B_OK || usb_disk_update_capacity(device) != B_OK) {
TRACE_ALWAYS("failed to read device data\n"); TRACE_ALWAYS("failed to read device data\n");
delete_sem(device->notify); delete_sem(device->notify);