Improve/fix lazy pipe creation introduced in 19032 based on suggestions by Michael and Marcus.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19034 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
ffffd44b12
commit
6177d112d4
|
@ -29,7 +29,7 @@ BusManager::BusManager(Stack *stack)
|
||||||
|
|
||||||
// Set the default pipes to NULL (these will be created when needed)
|
// Set the default pipes to NULL (these will be created when needed)
|
||||||
for (int32 i = 0; i <= USB_SPEED_MAX; i++)
|
for (int32 i = 0; i <= USB_SPEED_MAX; i++)
|
||||||
fDefaultPipes[i] = 0;
|
fDefaultPipes[i] = NULL;
|
||||||
|
|
||||||
fInitOK = true;
|
fInitOK = true;
|
||||||
}
|
}
|
||||||
|
@ -40,8 +40,7 @@ BusManager::~BusManager()
|
||||||
Lock();
|
Lock();
|
||||||
benaphore_destroy(&fLock);
|
benaphore_destroy(&fLock);
|
||||||
for (int32 i = 0; i <= USB_SPEED_MAX; i++)
|
for (int32 i = 0; i <= USB_SPEED_MAX; i++)
|
||||||
if (fDefaultPipes[i] != 0)
|
delete fDefaultPipes[i];
|
||||||
delete fDefaultPipes[i];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -100,7 +99,7 @@ BusManager::AllocateNewDevice(Hub *parent, usb_speed speed)
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE(("usb BusManager::AllocateNewDevice(): setting device address to %d\n", deviceAddress));
|
TRACE(("usb BusManager::AllocateNewDevice(): setting device address to %d\n", deviceAddress));
|
||||||
ControlPipe *defaultPipe = GetDefaultPipe(speed);
|
ControlPipe *defaultPipe = _GetDefaultPipe(speed);
|
||||||
|
|
||||||
if (!defaultPipe) {
|
if (!defaultPipe) {
|
||||||
TRACE(("usb BusManager::AllocateNewDevice(): Error getting the default pipe for speed %d\n", (int)speed));
|
TRACE(("usb BusManager::AllocateNewDevice(): Error getting the default pipe for speed %d\n", (int)speed));
|
||||||
|
@ -236,16 +235,20 @@ BusManager::NotifyPipeChange(Pipe *pipe, usb_change change)
|
||||||
}
|
}
|
||||||
|
|
||||||
ControlPipe *
|
ControlPipe *
|
||||||
BusManager::GetDefaultPipe(usb_speed speed)
|
BusManager::_GetDefaultPipe(usb_speed speed)
|
||||||
{
|
{
|
||||||
if (fDefaultPipes[(int)speed] == 0) {
|
if (!Lock())
|
||||||
fDefaultPipes[(int)speed] = new(std::nothrow) ControlPipe(fRootObject,
|
return NULL;
|
||||||
0, 0, (usb_speed)speed, 8);
|
|
||||||
if (!fDefaultPipes[(int)speed]) {
|
|
||||||
|
if (fDefaultPipes[speed] == NULL) {
|
||||||
|
fDefaultPipes[speed] = new(std::nothrow) ControlPipe(fRootObject,
|
||||||
|
0, 0, speed, 8);
|
||||||
|
if (!fDefaultPipes[speed]) {
|
||||||
TRACE_ERROR(("usb BusManager: failed to allocate default pipe\n"));
|
TRACE_ERROR(("usb BusManager: failed to allocate default pipe\n"));
|
||||||
return 0;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return fDefaultPipes[(int)speed];
|
return fDefaultPipes[speed];
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "BeOSCompatibility.h"
|
#include "BeOSCompatibility.h"
|
||||||
|
|
||||||
|
|
||||||
#define TRACE_USB
|
//#define TRACE_USB
|
||||||
#ifdef TRACE_USB
|
#ifdef TRACE_USB
|
||||||
#define TRACE(x) dprintf x
|
#define TRACE(x) dprintf x
|
||||||
#define TRACE_ERROR(x) dprintf x
|
#define TRACE_ERROR(x) dprintf x
|
||||||
|
@ -182,7 +182,7 @@ protected:
|
||||||
bool fInitOK;
|
bool fInitOK;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ControlPipe *GetDefaultPipe(usb_speed);
|
ControlPipe *_GetDefaultPipe(usb_speed);
|
||||||
|
|
||||||
benaphore fLock;
|
benaphore fLock;
|
||||||
bool fDeviceMap[128];
|
bool fDeviceMap[128];
|
||||||
|
|
Loading…
Reference in New Issue