Exemplo n.º 1
0
static status_t
usb_hid_free(void *cookie)
{
	TRACE("free(%p)\n", cookie);
	mutex_lock(&sDriverLock);

	HIDDevice *device = ((ProtocolHandler *)cookie)->Device();
	if (device->IsOpen()) {
		// another handler of this device is still open so we can't free it
	} else if (device->IsRemoved()) {
		// the parent device is removed already and none of its handlers are
		// open anymore so we can free it here
		for (uint32 i = 0;; i++) {
			ProtocolHandler *handler = device->ProtocolHandlerAt(i);
			if (handler == NULL)
				break;

			gDeviceList->RemoveDevice(NULL, handler);
		}

		delete device;
	}

	mutex_unlock(&sDriverLock);
	return B_OK;
}
Exemplo n.º 2
0
static status_t
usb_hid_free(void *_cookie)
{
	device_cookie *cookie = (device_cookie *)_cookie;
	TRACE("free(%p)\n", cookie);

	mutex_lock(&sDriverLock);

	HIDDevice *device = cookie->handler->Device();
	if (device->IsOpen()) {
		// another handler of this device is still open so we can't free it
	} else if (device->IsRemoved()) {
		// the parent device is removed already and none of its handlers are
		// open anymore so we can free it here
		delete device;
	}

	mutex_unlock(&sDriverLock);

	delete cookie;
	return B_OK;
}