Example #1
0
static status_t
usb_hid_open(const char *name, uint32 flags, void **_cookie)
{
	TRACE("open(%s, %lu, %p)\n", name, flags, _cookie);

	device_cookie *cookie = new(std::nothrow) device_cookie();
	if (cookie == NULL)
		return B_NO_MEMORY;

	MutexLocker locker(sDriverLock);

	ProtocolHandler *handler = (ProtocolHandler *)gDeviceList->FindDevice(name);
	TRACE("  name %s: handler %p\n", name, handler);

	cookie->handler = handler;
	cookie->cookie = 0;

	status_t result = handler == NULL ? B_ENTRY_NOT_FOUND : B_OK;
	if (result == B_OK)
		result = handler->Open(flags, &cookie->cookie);

	if (result != B_OK) {
		delete cookie;
		return result;
	}

	*_cookie = cookie;

	return B_OK;
}
Example #2
0
static status_t
usb_hid_open(const char *name, uint32 flags, void **cookie)
{
	TRACE("open(%s, %lu, %p)\n", name, flags, cookie);
	mutex_lock(&sDriverLock);

	ProtocolHandler *handler = (ProtocolHandler *)gDeviceList->FindDevice(name);
	if (handler == NULL) {
		mutex_unlock(&sDriverLock);
		return B_ENTRY_NOT_FOUND;
	}

	status_t result = handler->Open(flags);
	*cookie = handler;
	mutex_unlock(&sDriverLock);
	return result;
}