From 63218bfd3f074ef39f43a12402a191cc34cee267 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Mon, 30 Jul 2007 12:54:20 +0000 Subject: [PATCH] Use a flag to cancel issuing new transfers instead of relying on a B_CANCELED. This should ensure that the hid driver does not use the device after the remove hook completes. Untested... git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21748 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/drivers/input/usb_hid/hid.c | 5 ++++- src/add-ons/kernel/drivers/input/usb_hid/hid.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/add-ons/kernel/drivers/input/usb_hid/hid.c b/src/add-ons/kernel/drivers/input/usb_hid/hid.c index 0d38489f67..67e722c2f2 100644 --- a/src/add-ons/kernel/drivers/input/usb_hid/hid.c +++ b/src/add-ons/kernel/drivers/input/usb_hid/hid.c @@ -339,6 +339,7 @@ create_device(const usb_device *dev, const usb_interface_info *ii, device->open = 0; device->open_fds = NULL; device->active = true; + device->unplugged = false; device->insns = NULL; device->num_insns = 0; device->flags = 0; @@ -584,7 +585,7 @@ usb_callback(void *cookie, uint32 busStatus, hid_device_info *device = cookie; status_t status; - if (device == NULL) + if (device == NULL || device->unplugged) return; acquire_sem(device->sem_lock); @@ -849,6 +850,8 @@ hid_device_removed(void *cookie) assert (cookie != NULL); DPRINTF_INFO((MY_ID "device_removed(%s)\n", device->name)); + + device->unplugged = true; usb->cancel_queued_transfers (device->ept->handle); remove_device_info(device); diff --git a/src/add-ons/kernel/drivers/input/usb_hid/hid.h b/src/add-ons/kernel/drivers/input/usb_hid/hid.h index 4752867516..294cb9d05f 100644 --- a/src/add-ons/kernel/drivers/input/usb_hid/hid.h +++ b/src/add-ons/kernel/drivers/input/usb_hid/hid.h @@ -68,6 +68,7 @@ typedef struct hid_device_info { struct ring_buffer *rbuf; bool active; + bool unplugged; int open; struct driver_cookie *open_fds;