Commit c3bfc1b7 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

winebus: Fix DEVICE_RELATIONS content on device removal.

parent cc395391
...@@ -45,6 +45,7 @@ DEVICE_OBJECT *bus_create_hid_device(const WCHAR *busidW, WORD vid, WORD pid, ...@@ -45,6 +45,7 @@ DEVICE_OBJECT *bus_create_hid_device(const WCHAR *busidW, WORD vid, WORD pid,
WORD input, DWORD version, DWORD uid, const WCHAR *serialW, BOOL is_gamepad, WORD input, DWORD version, DWORD uid, const WCHAR *serialW, BOOL is_gamepad,
const platform_vtbl *vtbl, DWORD platform_data_size) DECLSPEC_HIDDEN; const platform_vtbl *vtbl, DWORD platform_data_size) DECLSPEC_HIDDEN;
DEVICE_OBJECT *bus_find_hid_device(const platform_vtbl *vtbl, void *platform_dev) DECLSPEC_HIDDEN; DEVICE_OBJECT *bus_find_hid_device(const platform_vtbl *vtbl, void *platform_dev) DECLSPEC_HIDDEN;
void bus_unlink_hid_device(DEVICE_OBJECT *device) DECLSPEC_HIDDEN;
void bus_remove_hid_device(DEVICE_OBJECT *device) DECLSPEC_HIDDEN; void bus_remove_hid_device(DEVICE_OBJECT *device) DECLSPEC_HIDDEN;
void process_hid_report(DEVICE_OBJECT *device, BYTE *report, DWORD length) DECLSPEC_HIDDEN; void process_hid_report(DEVICE_OBJECT *device, BYTE *report, DWORD length) DECLSPEC_HIDDEN;
DEVICE_OBJECT* bus_enumerate_hid_devices(const platform_vtbl *vtbl, enum_func function, void* context) DECLSPEC_HIDDEN; DEVICE_OBJECT* bus_enumerate_hid_devices(const platform_vtbl *vtbl, enum_func function, void* context) DECLSPEC_HIDDEN;
......
...@@ -368,6 +368,7 @@ static void handle_RemovalCallback(void *context, IOReturn result, void *sender, ...@@ -368,6 +368,7 @@ static void handle_RemovalCallback(void *context, IOReturn result, void *sender,
device = bus_find_hid_device(&iohid_vtbl, IOHIDDevice); device = bus_find_hid_device(&iohid_vtbl, IOHIDDevice);
if (device) if (device)
{ {
bus_unlink_hid_device(device);
IoInvalidateDeviceRelations(bus_pdo, BusRelations); IoInvalidateDeviceRelations(bus_pdo, BusRelations);
bus_remove_hid_device(device); bus_remove_hid_device(device);
} }
......
...@@ -899,6 +899,7 @@ static void try_remove_device(SDL_JoystickID id) ...@@ -899,6 +899,7 @@ static void try_remove_device(SDL_JoystickID id)
sdl_controller = private->sdl_controller; sdl_controller = private->sdl_controller;
sdl_haptic = private->sdl_haptic; sdl_haptic = private->sdl_haptic;
bus_unlink_hid_device(device);
IoInvalidateDeviceRelations(bus_pdo, BusRelations); IoInvalidateDeviceRelations(bus_pdo, BusRelations);
bus_remove_hid_device(device); bus_remove_hid_device(device);
...@@ -988,6 +989,7 @@ static void try_add_device(unsigned int index) ...@@ -988,6 +989,7 @@ static void try_add_device(unsigned int index)
if (!rc) if (!rc)
{ {
ERR("Building report descriptor failed, removing device\n"); ERR("Building report descriptor failed, removing device\n");
bus_unlink_hid_device(device);
bus_remove_hid_device(device); bus_remove_hid_device(device);
HeapFree(GetProcessHeap(), 0, serial); HeapFree(GetProcessHeap(), 0, serial);
return; return;
......
...@@ -1259,6 +1259,7 @@ static void try_add_device(struct udev_device *dev) ...@@ -1259,6 +1259,7 @@ static void try_add_device(struct udev_device *dev)
ERR("Building report descriptor failed, removing device\n"); ERR("Building report descriptor failed, removing device\n");
close(fd); close(fd);
udev_device_unref(dev); udev_device_unref(dev);
bus_unlink_hid_device(device);
bus_remove_hid_device(device); bus_remove_hid_device(device);
HeapFree(GetProcessHeap(), 0, serial); HeapFree(GetProcessHeap(), 0, serial);
return; return;
...@@ -1293,6 +1294,7 @@ static void try_remove_device(struct udev_device *dev) ...@@ -1293,6 +1294,7 @@ static void try_remove_device(struct udev_device *dev)
#endif #endif
if (!device) return; if (!device) return;
bus_unlink_hid_device(device);
IoInvalidateDeviceRelations(bus_pdo, BusRelations); IoInvalidateDeviceRelations(bus_pdo, BusRelations);
private = impl_from_DEVICE_OBJECT(device); private = impl_from_DEVICE_OBJECT(device);
......
...@@ -346,6 +346,16 @@ DEVICE_OBJECT* bus_enumerate_hid_devices(const platform_vtbl *vtbl, enum_func fu ...@@ -346,6 +346,16 @@ DEVICE_OBJECT* bus_enumerate_hid_devices(const platform_vtbl *vtbl, enum_func fu
return ret; return ret;
} }
void bus_unlink_hid_device(DEVICE_OBJECT *device)
{
struct device_extension *ext = (struct device_extension *)device->DeviceExtension;
struct pnp_device *pnp_device = ext->pnp_device;
EnterCriticalSection(&device_list_cs);
list_remove(&pnp_device->entry);
LeaveCriticalSection(&device_list_cs);
}
void bus_remove_hid_device(DEVICE_OBJECT *device) void bus_remove_hid_device(DEVICE_OBJECT *device)
{ {
struct device_extension *ext = (struct device_extension *)device->DeviceExtension; struct device_extension *ext = (struct device_extension *)device->DeviceExtension;
...@@ -355,10 +365,6 @@ void bus_remove_hid_device(DEVICE_OBJECT *device) ...@@ -355,10 +365,6 @@ void bus_remove_hid_device(DEVICE_OBJECT *device)
TRACE("(%p)\n", device); TRACE("(%p)\n", device);
EnterCriticalSection(&device_list_cs);
list_remove(&pnp_device->entry);
LeaveCriticalSection(&device_list_cs);
/* Cancel pending IRPs */ /* Cancel pending IRPs */
EnterCriticalSection(&ext->report_cs); EnterCriticalSection(&ext->report_cs);
while ((entry = RemoveHeadList(&ext->irp_queue)) != &ext->irp_queue) while ((entry = RemoveHeadList(&ext->irp_queue)) != &ext->irp_queue)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment