usb_hid: properly device remove handling
Small fix to device remove handling, when multiple hid-devices published on multiple interfaces. Fixes #18008. Change-Id: I64e1a9fb6cbac503e3d55b51ee0539bb6f1908e4 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5773 Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org> Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
This commit is contained in:
parent
4f18dc0496
commit
afe965f464
@ -192,6 +192,8 @@ usb_hid_device_removed(void *cookie)
|
||||
int32 parentCookie = (int32)(addr_t)cookie;
|
||||
TRACE("device_removed(%" B_PRId32 ")\n", parentCookie);
|
||||
|
||||
// removed device may contain multiple HID devices on multiple interfaces
|
||||
// we must go through all published devices and remove all that belong to this parent
|
||||
for (int32 i = 0; i < gDeviceList->CountDevices(); i++) {
|
||||
ProtocolHandler *handler = (ProtocolHandler *)gDeviceList->DeviceAt(i);
|
||||
if (!handler)
|
||||
@ -202,12 +204,13 @@ usb_hid_device_removed(void *cookie)
|
||||
continue;
|
||||
|
||||
// remove all the handlers
|
||||
for (uint32 i = 0;; i++) {
|
||||
handler = device->ProtocolHandlerAt(i);
|
||||
for (uint32 j = 0;; j++) {
|
||||
handler = device->ProtocolHandlerAt(j);
|
||||
if (handler == NULL)
|
||||
break;
|
||||
|
||||
gDeviceList->RemoveDevice(NULL, handler);
|
||||
i--; // device count changed, adjust index
|
||||
}
|
||||
|
||||
// this handler's device belongs to the one removed
|
||||
@ -216,8 +219,6 @@ usb_hid_device_removed(void *cookie)
|
||||
device->Removed();
|
||||
} else
|
||||
delete device;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
mutex_unlock(&sDriverLock);
|
||||
|
Loading…
x
Reference in New Issue
Block a user