* change overly large uint32 to uint8 as we only count to 12 max
* add additional tracing to usb_disk lun inquiry * cd and other optical disk devices can take some time to spin up when plugged. Now we give them some time to do so to ensure we can detect the media type properly if there is a cd in the drive. Things non-mechanical (flash drives) will continue almost immediately as there is no spin up time. The more attempts, the longer the wait. We now try 7 times (28 seconds total), my modern usb cdrom takes about 6 (21 seconds) of those cycles to be ready on power up and 4 (10 seconds) on media change while powered up. * tested with usb media and cd media. Doesn't introduce any visible delay to the user. * the write protected status in lun is now correct for my usb cd device on plug (it wasn't previously) * still seeing it though as read/write. Looking at this now. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42058 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
5cb190eda2
commit
ea9b910a26
@ -769,7 +769,8 @@ usb_disk_device_added(usb_device newDevice, void **cookie)
|
||||
|
||||
// initialize this lun
|
||||
result = usb_disk_inquiry(lun);
|
||||
for (uint32 tries = 0; tries < 3; tries++) {
|
||||
for (uint8 tries = 0; tries < 8; tries++) {
|
||||
TRACE("usb lun %d inquiry attempt %d begin\n", i, tries);
|
||||
status_t ready = usb_disk_test_unit_ready(lun);
|
||||
if (ready == B_OK || ready == B_DEV_NO_MEDIA) {
|
||||
if (ready == B_OK) {
|
||||
@ -779,12 +780,19 @@ usb_disk_device_added(usb_device newDevice, void **cookie)
|
||||
// some devices lock up when getting the mode sense
|
||||
else if (/*usb_disk_mode_sense(lun) != B_OK*/true)
|
||||
lun->write_protected = false;
|
||||
|
||||
TRACE("usb lun %d ready. write protected = %c\n", i,
|
||||
lun->write_protected ? 'y' : 'n');
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
TRACE("usb lun %d not ready, attempt %d\n", i, tries);
|
||||
}
|
||||
TRACE("usb lun %d inquiry attempt %d failed\n", i, tries);
|
||||
|
||||
snooze(10000);
|
||||
uint32_t snoozeTime = 1000000 * tries;
|
||||
TRACE("snoozing %u microseconds for usb lun\n", snoozeTime);
|
||||
snooze(snoozeTime);
|
||||
}
|
||||
|
||||
if (result != B_OK)
|
||||
|
Loading…
Reference in New Issue
Block a user