winebus.sys: Use Rtl CS functions.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2021-09-16 10:17:57 +02:00 committed by Alexandre Julliard
parent 35a6148acf
commit 39ca4de665
4 changed files with 43 additions and 43 deletions

View File

@ -180,9 +180,9 @@ static void iohid_device_stop(struct unix_device *iface)
IOHIDDeviceRegisterInputReportCallback(private->device, NULL, 0, NULL, NULL); IOHIDDeviceRegisterInputReportCallback(private->device, NULL, 0, NULL, NULL);
EnterCriticalSection(&iohid_cs); RtlEnterCriticalSection(&iohid_cs);
list_remove(&private->unix_device.entry); list_remove(&private->unix_device.entry);
LeaveCriticalSection(&iohid_cs); RtlLeaveCriticalSection(&iohid_cs);
} }
static NTSTATUS iohid_device_get_report_descriptor(struct unix_device *iface, BYTE *buffer, static NTSTATUS iohid_device_get_report_descriptor(struct unix_device *iface, BYTE *buffer,
@ -403,9 +403,9 @@ NTSTATUS iohid_bus_wait(void *args)
do do
{ {
if (bus_event_queue_pop(&event_queue, result)) return STATUS_PENDING; if (bus_event_queue_pop(&event_queue, result)) return STATUS_PENDING;
EnterCriticalSection(&iohid_cs); RtlEnterCriticalSection(&iohid_cs);
ret = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 10, TRUE); ret = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 10, TRUE);
LeaveCriticalSection(&iohid_cs); RtlLeaveCriticalSection(&iohid_cs);
} while (ret != kCFRunLoopRunStopped); } while (ret != kCFRunLoopRunStopped);
TRACE("IOHID main loop exiting\n"); TRACE("IOHID main loop exiting\n");

View File

@ -511,9 +511,9 @@ static void sdl_device_stop(struct unix_device *iface)
if (private->sdl_controller) pSDL_GameControllerClose(private->sdl_controller); if (private->sdl_controller) pSDL_GameControllerClose(private->sdl_controller);
if (private->sdl_haptic) pSDL_HapticClose(private->sdl_haptic); if (private->sdl_haptic) pSDL_HapticClose(private->sdl_haptic);
EnterCriticalSection(&sdl_cs); RtlEnterCriticalSection(&sdl_cs);
list_remove(&private->unix_device.entry); list_remove(&private->unix_device.entry);
LeaveCriticalSection(&sdl_cs); RtlLeaveCriticalSection(&sdl_cs);
} }
static NTSTATUS sdl_device_get_reportdescriptor(struct unix_device *iface, BYTE *buffer, static NTSTATUS sdl_device_get_reportdescriptor(struct unix_device *iface, BYTE *buffer,
@ -785,7 +785,7 @@ static void process_device_event(SDL_Event *event)
TRACE_(hid_report)("Received action %x\n", event->type); TRACE_(hid_report)("Received action %x\n", event->type);
EnterCriticalSection(&sdl_cs); RtlEnterCriticalSection(&sdl_cs);
if (event->type == SDL_JOYDEVICEADDED) if (event->type == SDL_JOYDEVICEADDED)
sdl_add_device(((SDL_JoyDeviceEvent *)event)->which); sdl_add_device(((SDL_JoyDeviceEvent *)event)->which);
@ -811,7 +811,7 @@ static void process_device_event(SDL_Event *event)
else WARN("failed to find device with id %d\n", id); else WARN("failed to find device with id %d\n", id);
} }
LeaveCriticalSection(&sdl_cs); RtlLeaveCriticalSection(&sdl_cs);
} }
NTSTATUS sdl_bus_init(void *args) NTSTATUS sdl_bus_init(void *args)

View File

@ -620,9 +620,9 @@ static void hidraw_device_destroy(struct unix_device *iface)
static NTSTATUS hidraw_device_start(struct unix_device *iface) static NTSTATUS hidraw_device_start(struct unix_device *iface)
{ {
EnterCriticalSection(&udev_cs); RtlEnterCriticalSection(&udev_cs);
start_polling_device(iface); start_polling_device(iface);
LeaveCriticalSection(&udev_cs); RtlLeaveCriticalSection(&udev_cs);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -630,10 +630,10 @@ static void hidraw_device_stop(struct unix_device *iface)
{ {
struct platform_private *private = impl_from_unix_device(iface); struct platform_private *private = impl_from_unix_device(iface);
EnterCriticalSection(&udev_cs); RtlEnterCriticalSection(&udev_cs);
stop_polling_device(iface); stop_polling_device(iface);
list_remove(&private->unix_device.entry); list_remove(&private->unix_device.entry);
LeaveCriticalSection(&udev_cs); RtlLeaveCriticalSection(&udev_cs);
} }
static NTSTATUS hidraw_device_get_report_descriptor(struct unix_device *iface, BYTE *buffer, static NTSTATUS hidraw_device_get_report_descriptor(struct unix_device *iface, BYTE *buffer,
@ -822,9 +822,9 @@ static NTSTATUS lnxev_device_start(struct unix_device *iface)
if ((status = build_report_descriptor(ext, ext->base.udev_device))) if ((status = build_report_descriptor(ext, ext->base.udev_device)))
return status; return status;
EnterCriticalSection(&udev_cs); RtlEnterCriticalSection(&udev_cs);
start_polling_device(iface); start_polling_device(iface);
LeaveCriticalSection(&udev_cs); RtlLeaveCriticalSection(&udev_cs);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -832,10 +832,10 @@ static void lnxev_device_stop(struct unix_device *iface)
{ {
struct wine_input_private *ext = input_impl_from_unix_device(iface); struct wine_input_private *ext = input_impl_from_unix_device(iface);
EnterCriticalSection(&udev_cs); RtlEnterCriticalSection(&udev_cs);
stop_polling_device(iface); stop_polling_device(iface);
list_remove(&ext->base.unix_device.entry); list_remove(&ext->base.unix_device.entry);
LeaveCriticalSection(&udev_cs); RtlLeaveCriticalSection(&udev_cs);
} }
static NTSTATUS lnxev_device_get_report_descriptor(struct unix_device *iface, BYTE *buffer, static NTSTATUS lnxev_device_get_report_descriptor(struct unix_device *iface, BYTE *buffer,
@ -1244,16 +1244,16 @@ NTSTATUS udev_bus_wait(void *args)
{ {
if (bus_event_queue_pop(&event_queue, result)) return STATUS_PENDING; if (bus_event_queue_pop(&event_queue, result)) return STATUS_PENDING;
EnterCriticalSection(&udev_cs); RtlEnterCriticalSection(&udev_cs);
while (close_count--) close(close_fds[close_count]); while (close_count--) close(close_fds[close_count]);
memcpy(pfd, poll_fds, poll_count * sizeof(*pfd)); memcpy(pfd, poll_fds, poll_count * sizeof(*pfd));
count = poll_count; count = poll_count;
close_count = 0; close_count = 0;
LeaveCriticalSection(&udev_cs); RtlLeaveCriticalSection(&udev_cs);
while (poll(pfd, count, -1) <= 0) {} while (poll(pfd, count, -1) <= 0) {}
EnterCriticalSection(&udev_cs); RtlEnterCriticalSection(&udev_cs);
if (pfd[0].revents) process_monitor_event(udev_monitor); if (pfd[0].revents) process_monitor_event(udev_monitor);
if (pfd[1].revents) read(deviceloop_control[0], &ctrl, 1); if (pfd[1].revents) read(deviceloop_control[0], &ctrl, 1);
for (i = 2; i < count; ++i) for (i = 2; i < count; ++i)
@ -1262,7 +1262,7 @@ NTSTATUS udev_bus_wait(void *args)
device = find_device_from_fd(pfd[i].fd); device = find_device_from_fd(pfd[i].fd);
if (device) device->read_report(&device->unix_device); if (device) device->read_report(&device->unix_device);
} }
LeaveCriticalSection(&udev_cs); RtlLeaveCriticalSection(&udev_cs);
} }
TRACE("UDEV main loop exiting\n"); TRACE("UDEV main loop exiting\n");

View File

@ -294,7 +294,7 @@ static DEVICE_OBJECT *bus_create_hid_device(struct device_desc *desc, struct uni
return NULL; return NULL;
} }
EnterCriticalSection(&device_list_cs); RtlEnterCriticalSection(&device_list_cs);
/* fill out device_extension struct */ /* fill out device_extension struct */
ext = (struct device_extension *)device->DeviceExtension; ext = (struct device_extension *)device->DeviceExtension;
@ -318,7 +318,7 @@ static DEVICE_OBJECT *bus_create_hid_device(struct device_desc *desc, struct uni
/* add to list of pnp devices */ /* add to list of pnp devices */
list_add_tail(&device_list, &ext->entry); list_add_tail(&device_list, &ext->entry);
LeaveCriticalSection(&device_list_cs); RtlLeaveCriticalSection(&device_list_cs);
return device; return device;
} }
@ -327,7 +327,7 @@ static DEVICE_OBJECT *bus_find_unix_device(struct unix_device *unix_device)
struct device_extension *ext; struct device_extension *ext;
DEVICE_OBJECT *ret = NULL; DEVICE_OBJECT *ret = NULL;
EnterCriticalSection(&device_list_cs); RtlEnterCriticalSection(&device_list_cs);
LIST_FOR_EACH_ENTRY(ext, &device_list, struct device_extension, entry) LIST_FOR_EACH_ENTRY(ext, &device_list, struct device_extension, entry)
{ {
if (ext->unix_device == unix_device) if (ext->unix_device == unix_device)
@ -336,7 +336,7 @@ static DEVICE_OBJECT *bus_find_unix_device(struct unix_device *unix_device)
break; break;
} }
} }
LeaveCriticalSection(&device_list_cs); RtlLeaveCriticalSection(&device_list_cs);
return ret; return ret;
} }
@ -345,9 +345,9 @@ static void bus_unlink_hid_device(DEVICE_OBJECT *device)
{ {
struct device_extension *ext = (struct device_extension *)device->DeviceExtension; struct device_extension *ext = (struct device_extension *)device->DeviceExtension;
EnterCriticalSection(&device_list_cs); RtlEnterCriticalSection(&device_list_cs);
list_remove(&ext->entry); list_remove(&ext->entry);
LeaveCriticalSection(&device_list_cs); RtlLeaveCriticalSection(&device_list_cs);
} }
static NTSTATUS build_device_relations(DEVICE_RELATIONS **devices) static NTSTATUS build_device_relations(DEVICE_RELATIONS **devices)
@ -355,12 +355,12 @@ static NTSTATUS build_device_relations(DEVICE_RELATIONS **devices)
struct device_extension *ext; struct device_extension *ext;
int i; int i;
EnterCriticalSection(&device_list_cs); RtlEnterCriticalSection(&device_list_cs);
*devices = ExAllocatePool(PagedPool, offsetof(DEVICE_RELATIONS, Objects[list_count(&device_list)])); *devices = ExAllocatePool(PagedPool, offsetof(DEVICE_RELATIONS, Objects[list_count(&device_list)]));
if (!*devices) if (!*devices)
{ {
LeaveCriticalSection(&device_list_cs); RtlLeaveCriticalSection(&device_list_cs);
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
} }
@ -371,7 +371,7 @@ static NTSTATUS build_device_relations(DEVICE_RELATIONS **devices)
call_fastcall_func1(ObfReferenceObject, ext->device); call_fastcall_func1(ObfReferenceObject, ext->device);
i++; i++;
} }
LeaveCriticalSection(&device_list_cs); RtlLeaveCriticalSection(&device_list_cs);
(*devices)->Count = i; (*devices)->Count = i;
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -415,7 +415,7 @@ static void process_hid_report(DEVICE_OBJECT *device, BYTE *report, DWORD length
if (!length || !report) if (!length || !report)
return; return;
EnterCriticalSection(&ext->cs); RtlEnterCriticalSection(&ext->cs);
if (length > ext->buffer_size) if (length > ext->buffer_size)
{ {
RtlFreeHeap(GetProcessHeap(), 0, ext->last_report); RtlFreeHeap(GetProcessHeap(), 0, ext->last_report);
@ -426,7 +426,7 @@ static void process_hid_report(DEVICE_OBJECT *device, BYTE *report, DWORD length
ext->buffer_size = 0; ext->buffer_size = 0;
ext->last_report_size = 0; ext->last_report_size = 0;
ext->last_report_read = TRUE; ext->last_report_read = TRUE;
LeaveCriticalSection(&ext->cs); RtlLeaveCriticalSection(&ext->cs);
return; return;
} }
else else
@ -449,7 +449,7 @@ static void process_hid_report(DEVICE_OBJECT *device, BYTE *report, DWORD length
ext->last_report_read = TRUE; ext->last_report_read = TRUE;
IoCompleteRequest(irp, IO_NO_INCREMENT); IoCompleteRequest(irp, IO_NO_INCREMENT);
} }
LeaveCriticalSection(&ext->cs); RtlLeaveCriticalSection(&ext->cs);
} }
static NTSTATUS handle_IRP_MN_QUERY_DEVICE_RELATIONS(IRP *irp) static NTSTATUS handle_IRP_MN_QUERY_DEVICE_RELATIONS(IRP *irp)
@ -564,11 +564,11 @@ static DWORD CALLBACK bus_main_thread(void *args)
{ {
case BUS_EVENT_TYPE_NONE: break; case BUS_EVENT_TYPE_NONE: break;
case BUS_EVENT_TYPE_DEVICE_REMOVED: case BUS_EVENT_TYPE_DEVICE_REMOVED:
EnterCriticalSection(&device_list_cs); RtlEnterCriticalSection(&device_list_cs);
device = bus_find_unix_device(event->device); device = bus_find_unix_device(event->device);
if (!device) WARN("could not find device for %s bus device %p\n", debugstr_w(bus.name), event->device); if (!device) WARN("could not find device for %s bus device %p\n", debugstr_w(bus.name), event->device);
else bus_unlink_hid_device(device); else bus_unlink_hid_device(device);
LeaveCriticalSection(&device_list_cs); RtlLeaveCriticalSection(&device_list_cs);
IoInvalidateDeviceRelations(bus_pdo, BusRelations); IoInvalidateDeviceRelations(bus_pdo, BusRelations);
break; break;
case BUS_EVENT_TYPE_DEVICE_CREATED: case BUS_EVENT_TYPE_DEVICE_CREATED:
@ -581,11 +581,11 @@ static DWORD CALLBACK bus_main_thread(void *args)
} }
break; break;
case BUS_EVENT_TYPE_INPUT_REPORT: case BUS_EVENT_TYPE_INPUT_REPORT:
EnterCriticalSection(&device_list_cs); RtlEnterCriticalSection(&device_list_cs);
device = bus_find_unix_device(event->device); device = bus_find_unix_device(event->device);
if (!device) WARN("could not find device for %s bus device %p\n", debugstr_w(bus.name), event->device); if (!device) WARN("could not find device for %s bus device %p\n", debugstr_w(bus.name), event->device);
else process_hid_report(device, event->input_report.buffer, event->input_report.length); else process_hid_report(device, event->input_report.buffer, event->input_report.length);
LeaveCriticalSection(&device_list_cs); RtlLeaveCriticalSection(&device_list_cs);
break; break;
} }
} }
@ -839,19 +839,19 @@ static NTSTATUS pdo_pnp_dispatch(DEVICE_OBJECT *device, IRP *irp)
break; break;
case IRP_MN_START_DEVICE: case IRP_MN_START_DEVICE:
EnterCriticalSection(&ext->cs); RtlEnterCriticalSection(&ext->cs);
if (ext->state != DEVICE_STATE_STOPPED) status = STATUS_SUCCESS; if (ext->state != DEVICE_STATE_STOPPED) status = STATUS_SUCCESS;
else if (ext->state == DEVICE_STATE_REMOVED) status = STATUS_DELETE_PENDING; else if (ext->state == DEVICE_STATE_REMOVED) status = STATUS_DELETE_PENDING;
else if (!(status = unix_device_start(device))) ext->state = DEVICE_STATE_STARTED; else if (!(status = unix_device_start(device))) ext->state = DEVICE_STATE_STARTED;
else ERR("failed to start device %p, status %#x\n", device, status); else ERR("failed to start device %p, status %#x\n", device, status);
LeaveCriticalSection(&ext->cs); RtlLeaveCriticalSection(&ext->cs);
break; break;
case IRP_MN_SURPRISE_REMOVAL: case IRP_MN_SURPRISE_REMOVAL:
EnterCriticalSection(&ext->cs); RtlEnterCriticalSection(&ext->cs);
remove_pending_irps(device); remove_pending_irps(device);
ext->state = DEVICE_STATE_REMOVED; ext->state = DEVICE_STATE_REMOVED;
LeaveCriticalSection(&ext->cs); RtlLeaveCriticalSection(&ext->cs);
status = STATUS_SUCCESS; status = STATUS_SUCCESS;
break; break;
@ -934,11 +934,11 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp)
return IoCallDriver(bus_pdo, irp); return IoCallDriver(bus_pdo, irp);
} }
EnterCriticalSection(&ext->cs); RtlEnterCriticalSection(&ext->cs);
if (ext->state == DEVICE_STATE_REMOVED) if (ext->state == DEVICE_STATE_REMOVED)
{ {
LeaveCriticalSection(&ext->cs); RtlLeaveCriticalSection(&ext->cs);
irp->IoStatus.Status = STATUS_DELETE_PENDING; irp->IoStatus.Status = STATUS_DELETE_PENDING;
IoCompleteRequest(irp, IO_NO_INCREMENT); IoCompleteRequest(irp, IO_NO_INCREMENT);
return STATUS_DELETE_PENDING; return STATUS_DELETE_PENDING;
@ -1072,7 +1072,7 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp)
} }
status = irp->IoStatus.Status; status = irp->IoStatus.Status;
LeaveCriticalSection(&ext->cs); RtlLeaveCriticalSection(&ext->cs);
if (status != STATUS_PENDING) IoCompleteRequest(irp, IO_NO_INCREMENT); if (status != STATUS_PENDING) IoCompleteRequest(irp, IO_NO_INCREMENT);
return status; return status;