Example #1
0
// Called with the mutex lock already held
BOOL OpenContext::PutDevice(UKWD_USB_DEVICE DeviceIdentifier)
{
	MutexLocker lock(mMutex);
	DevicePtr dev (mDevice->GetDeviceList(), DeviceIdentifier);
	if (!Validate(dev)) {
		SetLastError(ERROR_INVALID_HANDLE);
		return FALSE;
	}
	mOpenDevices.erase(dev.Get());
	// Put for the reference in mOpenDevices
	mDevice->GetDeviceList()->PutDevice(dev.Get());
	return TRUE;
}
Example #2
0
// Checks that device is valid and is open
// by this context.
BOOL OpenContext::Validate(DevicePtr& device)
{
	if (!device.Valid())
		return FALSE;
	PtrArray<UsbDevice>::iterator it
		= mOpenDevices.find(device.Get());
	if (it == mOpenDevices.end()) {
	    WARN_MSG((TEXT("USBKWrapperDrv!OpenContext::Validate")
			TEXT(" - failed to find device in this context for identifier 0x%08x\r\n"),
			device->GetIdentifier()));
		return FALSE;
	} 
	return TRUE;
}