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! // new device attached!
TRACE_ALWAYS("port %ld: new device connected\n", i); TRACE_ALWAYS("port %ld: new device connected\n", i);
int32 retry = 2;
while (retry--) {
// wait some time for the device to power up // wait some time for the device to power up
snooze(USB_DELAY_DEVICE_POWER_UP); snooze(USB_DELAY_DEVICE_POWER_UP);
@@ -225,21 +227,22 @@ Hub::Explore(change_item **changeList)
result = ResetPort(i); result = ResetPort(i);
if (result < B_OK) { if (result < B_OK) {
TRACE_ERROR("resetting port %ld failed\n", i); TRACE_ERROR("resetting port %ld failed\n", i);
continue; break;
} }
result = UpdatePortStatus(i); result = UpdatePortStatus(i);
if (result < B_OK) if (result < B_OK)
continue; break;
if ((fPortStatus[i].status & PORT_STATUS_CONNECTION) == 0) { if ((fPortStatus[i].status & PORT_STATUS_CONNECTION) == 0) {
// device has vanished after reset, ignore // device has vanished after reset, ignore
TRACE("device disappeared on reset\n"); TRACE("device disappeared on reset\n");
continue; break;
} }
if (fChildren[i] != NULL) { 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]->Changed(changeList, false);
fChildren[i] = NULL; fChildren[i] = NULL;
} }
@@ -251,9 +254,9 @@ Hub::Explore(change_item **changeList)
speed = USB_SPEED_HIGHSPEED; speed = USB_SPEED_HIGHSPEED;
// either let the device inherit our addresses (if we are // either let the device inherit our addresses (if we are
// already potentially using a transaction translator) or set // already potentially using a transaction translator) or
// ourselfs as the hub when we might become the transaction // set ourselfs as the hub when we might become the
// translator for the device. // transaction translator for the device.
int8 hubAddress = HubAddress(); int8 hubAddress = HubAddress();
uint8 hubPort = HubPort(); uint8 hubPort = HubPort();
if (Speed() == USB_SPEED_HIGHSPEED) { if (Speed() == USB_SPEED_HIGHSPEED) {
@@ -267,12 +270,14 @@ Hub::Explore(change_item **changeList)
if (newDevice) { if (newDevice) {
newDevice->Changed(changeList, true); newDevice->Changed(changeList, true);
fChildren[i] = newDevice; fChildren[i] = newDevice;
break;
} else { } else {
// the device failed to setup correctly, disable the port // the device failed to setup correctly, disable the
// so that the device doesn't get in the way of future // port so that the device doesn't get in the way of
// addressing. // future addressing.
DisablePort(i); DisablePort(i);
} }
}
} else { } else {
// Device removed... // Device removed...
TRACE_ALWAYS("port %ld: device removed\n", i); TRACE_ALWAYS("port %ld: device removed\n", i);