Commit 05fe2f3f authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

wineusb.sys: Move the libusb_init() and libusb_exit() calls to the Unix library.

parent 03034f2c
...@@ -173,12 +173,19 @@ static NTSTATUS usb_main_loop(void *args) ...@@ -173,12 +173,19 @@ static NTSTATUS usb_main_loop(void *args)
TRACE("Starting libusb event thread.\n"); TRACE("Starting libusb event thread.\n");
if ((ret = libusb_init(NULL)))
{
ERR("Failed to initialize libusb: %s\n", libusb_strerror(ret));
return STATUS_UNSUCCESSFUL;
}
if ((ret = libusb_hotplug_register_callback(NULL, if ((ret = libusb_hotplug_register_callback(NULL,
LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED | LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT, LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED | LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT,
LIBUSB_HOTPLUG_ENUMERATE, LIBUSB_HOTPLUG_MATCH_ANY, LIBUSB_HOTPLUG_MATCH_ANY, LIBUSB_HOTPLUG_ENUMERATE, LIBUSB_HOTPLUG_MATCH_ANY, LIBUSB_HOTPLUG_MATCH_ANY,
LIBUSB_HOTPLUG_MATCH_ANY, hotplug_cb, NULL, &hotplug_cb_handle))) LIBUSB_HOTPLUG_MATCH_ANY, hotplug_cb, NULL, &hotplug_cb_handle)))
{ {
ERR("Failed to register callback: %s\n", libusb_strerror(ret)); ERR("Failed to register callback: %s\n", libusb_strerror(ret));
libusb_exit(NULL);
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
...@@ -188,6 +195,8 @@ static NTSTATUS usb_main_loop(void *args) ...@@ -188,6 +195,8 @@ static NTSTATUS usb_main_loop(void *args)
ERR("Error handling events: %s\n", libusb_strerror(ret)); ERR("Error handling events: %s\n", libusb_strerror(ret));
} }
libusb_exit(NULL);
queue_event(&shutdown_event); queue_event(&shutdown_event);
TRACE("Shutting down libusb event thread.\n"); TRACE("Shutting down libusb event thread.\n");
......
...@@ -731,14 +731,12 @@ static NTSTATUS WINAPI driver_add_device(DRIVER_OBJECT *driver, DEVICE_OBJECT *p ...@@ -731,14 +731,12 @@ static NTSTATUS WINAPI driver_add_device(DRIVER_OBJECT *driver, DEVICE_OBJECT *p
static void WINAPI driver_unload(DRIVER_OBJECT *driver) static void WINAPI driver_unload(DRIVER_OBJECT *driver)
{ {
libusb_exit(NULL);
} }
NTSTATUS WINAPI DriverEntry(DRIVER_OBJECT *driver, UNICODE_STRING *path) NTSTATUS WINAPI DriverEntry(DRIVER_OBJECT *driver, UNICODE_STRING *path)
{ {
NTSTATUS status; NTSTATUS status;
void *instance; void *instance;
int err;
TRACE("driver %p, path %s.\n", driver, debugstr_w(path->Buffer)); TRACE("driver %p, path %s.\n", driver, debugstr_w(path->Buffer));
...@@ -752,12 +750,6 @@ NTSTATUS WINAPI DriverEntry(DRIVER_OBJECT *driver, UNICODE_STRING *path) ...@@ -752,12 +750,6 @@ NTSTATUS WINAPI DriverEntry(DRIVER_OBJECT *driver, UNICODE_STRING *path)
driver_obj = driver; driver_obj = driver;
if ((err = libusb_init(NULL)))
{
ERR("Failed to initialize libusb: %s\n", libusb_strerror(err));
return STATUS_UNSUCCESSFUL;
}
driver->DriverExtension->AddDevice = driver_add_device; driver->DriverExtension->AddDevice = driver_add_device;
driver->DriverUnload = driver_unload; driver->DriverUnload = driver_unload;
driver->MajorFunction[IRP_MJ_PNP] = driver_pnp; driver->MajorFunction[IRP_MJ_PNP] = driver_pnp;
......
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