If device allocation fails, retry the attach process, i.e. reset and initialize

the device again. Makes Axel's USB stick work and might also help with other
(broken) devices.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36234 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz
2010-04-13 18:26:26 +00:00
parent a1b2e9e959
commit 696914f907
+15 -10
View File
@@ -218,6 +218,8 @@ Hub::Explore(change_item **changeList)
// new device attached!
TRACE_ALWAYS("port %ld: new device connected\n", i);
int32 retry = 2;
while (retry--) {
// wait some time for the device to power up
snooze(USB_DELAY_DEVICE_POWER_UP);
@@ -225,21 +227,22 @@ Hub::Explore(change_item **changeList)
result = ResetPort(i);
if (result < B_OK) {
TRACE_ERROR("resetting port %ld failed\n", i);
continue;
break;
}
result = UpdatePortStatus(i);
if (result < B_OK)
continue;
break;
if ((fPortStatus[i].status & PORT_STATUS_CONNECTION) == 0) {
// device has vanished after reset, ignore
TRACE("device disappeared on reset\n");
continue;
break;
}
if (fChildren[i] != NULL) {
TRACE_ERROR("new device on a port that is already in use\n");
TRACE_ERROR("new device on a port that is already in "
"use\n");
fChildren[i]->Changed(changeList, false);
fChildren[i] = NULL;
}
@@ -251,9 +254,9 @@ Hub::Explore(change_item **changeList)
speed = USB_SPEED_HIGHSPEED;
// either let the device inherit our addresses (if we are
// already potentially using a transaction translator) or set
// ourselfs as the hub when we might become the transaction
// translator for the device.
// already potentially using a transaction translator) or
// set ourselfs as the hub when we might become the
// transaction translator for the device.
int8 hubAddress = HubAddress();
uint8 hubPort = HubPort();
if (Speed() == USB_SPEED_HIGHSPEED) {
@@ -267,12 +270,14 @@ Hub::Explore(change_item **changeList)
if (newDevice) {
newDevice->Changed(changeList, true);
fChildren[i] = newDevice;
break;
} else {
// the device failed to setup correctly, disable the port
// so that the device doesn't get in the way of future
// addressing.
// the device failed to setup correctly, disable the
// port so that the device doesn't get in the way of
// future addressing.
DisablePort(i);
}
}
} else {
// Device removed...
TRACE_ALWAYS("port %ld: device removed\n", i);