USB: Properly assign IDs to USB Bus Managers (HCI drivers).

Previously they would just get -1, as the BusManager class
would request their ID before they had been added to the Stack.
Now we add them to the stack inside ::Start(), rather than letting
the individual drivers do that just after ::Start(), and then assign
the ID there directly.
This commit is contained in:
Augustin Cavalier 2019-02-19 17:14:54 -05:00
parent d6f3954f39
commit a182f19364
5 changed files with 19 additions and 9 deletions

View File

@ -14,7 +14,7 @@ BusManager::BusManager(Stack *stack)
: fInitOK(false), : fInitOK(false),
fStack(stack), fStack(stack),
fRootHub(NULL), fRootHub(NULL),
fUSBID(fStack->IndexOfBusManager(this)) fUSBID((uint32)-1)
{ {
mutex_init(&fLock, "usb busmanager lock"); mutex_init(&fLock, "usb busmanager lock");
@ -253,6 +253,8 @@ BusManager::FreeDevice(Device *device)
status_t status_t
BusManager::Start() BusManager::Start()
{ {
fStack->AddBusManager(this);
fUSBID = fStack->IndexOfBusManager(this);
return B_OK; return B_OK;
} }

View File

@ -1216,8 +1216,10 @@ EHCI::AddTo(Stack *stack)
// the bus took it away // the bus took it away
item = new(std::nothrow) pci_info; item = new(std::nothrow) pci_info;
bus->Start(); if (bus->Start() != B_OK) {
stack->AddBusManager(bus); delete bus;
continue;
}
found = true; found = true;
} }
} }

View File

@ -647,8 +647,10 @@ OHCI::AddTo(Stack *stack)
// the bus took it away // the bus took it away
item = new(std::nothrow) pci_info; item = new(std::nothrow) pci_info;
bus->Start(); if (bus->Start() != B_OK) {
stack->AddBusManager(bus); delete bus;
continue;
}
found = true; found = true;
} }
} }

View File

@ -1923,8 +1923,10 @@ UHCI::AddTo(Stack *stack)
// the bus took it away // the bus took it away
item = new(std::nothrow) pci_info; item = new(std::nothrow) pci_info;
bus->Start(); if (bus->Start() != B_OK) {
stack->AddBusManager(bus); delete bus;
continue;
}
found = true; found = true;
} }
} }

View File

@ -864,8 +864,10 @@ XHCI::AddTo(Stack *stack)
// the bus took it away // the bus took it away
item = new(std::nothrow) pci_info; item = new(std::nothrow) pci_info;
bus->Start(); if (bus->Start() != B_OK) {
stack->AddBusManager(bus); delete bus;
continue;
}
found = true; found = true;
} }
} }