Retry reading the capacity up to three times. The first try might only yield a

unit attention telling us that the device or media status changed, which is
expected.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26081 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz
2008-06-22 15:02:35 +00:00
parent 57e81ac7d8
commit 717b5b78ce
@@ -415,8 +415,14 @@ usb_disk_update_capacity(device_lun *lun)
{
uint32 dataLength = sizeof(scsi_read_capacity_10_parameter);
scsi_read_capacity_10_parameter parameter;
status_t result = usb_disk_operation(lun, SCSI_READ_CAPACITY_10, 10, 0, 0,
&parameter, &dataLength, true);
status_t result = B_ERROR;
for (int32 i = 0; i < 3; i++) {
result = usb_disk_operation(lun, SCSI_READ_CAPACITY_10, 10, 0, 0,
&parameter, &dataLength, true);
if (result == B_OK)
break;
}
if (result != B_OK) {
TRACE_ALWAYS("failed to update capacity\n");
lun->media_present = false;