Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/hidclass.sys/device.c | 96 ++++++++++++++------------------------ 1 file changed, 35 insertions(+), 61 deletions(-)
diff --git a/dlls/hidclass.sys/device.c b/dlls/hidclass.sys/device.c index 73a8428ad22..b8e3061b274 100644 --- a/dlls/hidclass.sys/device.c +++ b/dlls/hidclass.sys/device.c @@ -157,13 +157,11 @@ static void HID_Device_processQueue(DEVICE_OBJECT *device) RingBuffer_Read(ext->u.pdo.ring_buffer, ptr, packet, &buffer_size); if (buffer_size) { - NTSTATUS rc; ULONG out_length; IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation(irp); packet->reportBuffer = (BYTE *)packet + sizeof(*packet); TRACE_(hid_report)("Processing Request (%i)\n",ptr); - rc = copy_packet_into_buffer(packet, irp->AssociatedIrp.SystemBuffer, irpsp->Parameters.Read.Length, &out_length); - irp->IoStatus.Status = rc; + irp->IoStatus.Status = copy_packet_into_buffer( packet, irp->AssociatedIrp.SystemBuffer, irpsp->Parameters.Read.Length, &out_length ); irp->IoStatus.Information = out_length; } else @@ -272,7 +270,7 @@ void HID_StartDeviceThread(DEVICE_OBJECT *device) ext->u.pdo.thread = CreateThread(NULL, 0, hid_device_thread, device, 0, NULL); }
-static NTSTATUS handle_IOCTL_HID_GET_COLLECTION_INFORMATION(IRP *irp, BASE_DEVICE_EXTENSION *ext) +static void handle_IOCTL_HID_GET_COLLECTION_INFORMATION( IRP *irp, BASE_DEVICE_EXTENSION *ext ) { IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation( irp ); if (irpsp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(HID_COLLECTION_INFORMATION)) @@ -286,10 +284,9 @@ static NTSTATUS handle_IOCTL_HID_GET_COLLECTION_INFORMATION(IRP *irp, BASE_DEVIC irp->IoStatus.Information = sizeof(HID_COLLECTION_INFORMATION); irp->IoStatus.Status = STATUS_SUCCESS; } - return STATUS_SUCCESS; }
-static NTSTATUS handle_IOCTL_HID_GET_COLLECTION_DESCRIPTOR(IRP *irp, BASE_DEVICE_EXTENSION *ext) +static void handle_IOCTL_HID_GET_COLLECTION_DESCRIPTOR( IRP *irp, BASE_DEVICE_EXTENSION *ext ) { IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation( irp ); const WINE_HIDP_PREPARSED_DATA *data = ext->u.pdo.preparsed_data; @@ -305,10 +302,9 @@ static NTSTATUS handle_IOCTL_HID_GET_COLLECTION_DESCRIPTOR(IRP *irp, BASE_DEVICE irp->IoStatus.Information = data->dwSize; irp->IoStatus.Status = STATUS_SUCCESS; } - return STATUS_SUCCESS; }
-static NTSTATUS handle_minidriver_string(BASE_DEVICE_EXTENSION *ext, IRP *irp, SHORT index) +static void handle_minidriver_string( BASE_DEVICE_EXTENSION *ext, IRP *irp, SHORT index ) { IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation( irp ); WCHAR buffer[127]; @@ -328,16 +324,13 @@ static NTSTATUS handle_minidriver_string(BASE_DEVICE_EXTENSION *ext, IRP *irp, S irp->IoStatus.Information = (lstrlenW(buffer)+1) * sizeof(WCHAR); } irp->IoStatus.Status = status; - - return STATUS_SUCCESS; }
-static NTSTATUS HID_get_feature(BASE_DEVICE_EXTENSION *ext, IRP *irp) +static void HID_get_feature( BASE_DEVICE_EXTENSION *ext, IRP *irp ) { IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation( irp ); HID_XFER_PACKET *packet; DWORD len; - NTSTATUS rc = STATUS_SUCCESS; BYTE *out_buffer;
irp->IoStatus.Information = 0; @@ -348,7 +341,7 @@ static NTSTATUS HID_get_feature(BASE_DEVICE_EXTENSION *ext, IRP *irp) if (!irpsp->Parameters.DeviceIoControl.OutputBufferLength || !out_buffer) { irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL; - return rc; + return; }
len = sizeof(*packet) + irpsp->Parameters.DeviceIoControl.OutputBufferLength; @@ -359,9 +352,8 @@ static NTSTATUS HID_get_feature(BASE_DEVICE_EXTENSION *ext, IRP *irp)
TRACE_(hid_report)("(id %i, len %i buffer %p)\n", packet->reportId, packet->reportBufferLen, packet->reportBuffer);
- rc = call_minidriver(IOCTL_HID_GET_FEATURE, ext->u.pdo.parent_fdo, NULL, 0, packet, sizeof(*packet)); + irp->IoStatus.Status = call_minidriver( IOCTL_HID_GET_FEATURE, ext->u.pdo.parent_fdo, NULL, 0, packet, sizeof(*packet) );
- irp->IoStatus.Status = rc; if (irp->IoStatus.Status == STATUS_SUCCESS) { irp->IoStatus.Information = packet->reportBufferLen; @@ -370,21 +362,18 @@ static NTSTATUS HID_get_feature(BASE_DEVICE_EXTENSION *ext, IRP *irp) else irp->IoStatus.Information = 0;
- TRACE_(hid_report)("Result 0x%x get %li bytes\n", rc, irp->IoStatus.Information); + TRACE_(hid_report)( "Result 0x%x get %li bytes\n", irp->IoStatus.Status, irp->IoStatus.Information );
free(packet); - - return rc; }
-static NTSTATUS HID_set_to_device(DEVICE_OBJECT *device, IRP *irp) +static void HID_set_to_device( DEVICE_OBJECT *device, IRP *irp ) { IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation(irp); BASE_DEVICE_EXTENSION *ext = device->DeviceExtension; const WINE_HIDP_PREPARSED_DATA *data = ext->u.pdo.preparsed_data; HID_XFER_PACKET packet; ULONG max_len; - NTSTATUS rc;
TRACE_(hid_report)("Device %p Buffer length %i Buffer %p\n", device, irpsp->Parameters.DeviceIoControl.InputBufferLength, irp->AssociatedIrp.SystemBuffer); packet.reportId = ((BYTE*)irp->AssociatedIrp.SystemBuffer)[0]; @@ -412,23 +401,19 @@ static NTSTATUS HID_set_to_device(DEVICE_OBJECT *device, IRP *irp)
TRACE_(hid_report)("(id %i, len %i buffer %p)\n", packet.reportId, packet.reportBufferLen, packet.reportBuffer);
- rc = call_minidriver(irpsp->Parameters.DeviceIoControl.IoControlCode, - ext->u.pdo.parent_fdo, NULL, 0, &packet, sizeof(packet)); + irp->IoStatus.Status = call_minidriver( irpsp->Parameters.DeviceIoControl.IoControlCode, + ext->u.pdo.parent_fdo, NULL, 0, &packet, sizeof(packet) );
- irp->IoStatus.Status = rc; if (irp->IoStatus.Status == STATUS_SUCCESS) irp->IoStatus.Information = irpsp->Parameters.DeviceIoControl.InputBufferLength; else irp->IoStatus.Information = 0;
- TRACE_(hid_report)("Result 0x%x set %li bytes\n", rc, irp->IoStatus.Information); - - return rc; + TRACE_(hid_report)( "Result 0x%x set %li bytes\n", irp->IoStatus.Status, irp->IoStatus.Information ); }
NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp) { - NTSTATUS rc = STATUS_SUCCESS; IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation( irp ); BASE_DEVICE_EXTENSION *ext = device->DeviceExtension; BOOL removed; @@ -484,27 +469,27 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp) } case IOCTL_HID_GET_PRODUCT_STRING: { - rc = handle_minidriver_string(ext, irp, HID_STRING_ID_IPRODUCT); + handle_minidriver_string( ext, irp, HID_STRING_ID_IPRODUCT ); break; } case IOCTL_HID_GET_SERIALNUMBER_STRING: { - rc = handle_minidriver_string(ext, irp, HID_STRING_ID_ISERIALNUMBER); + handle_minidriver_string( ext, irp, HID_STRING_ID_ISERIALNUMBER ); break; } case IOCTL_HID_GET_MANUFACTURER_STRING: { - rc = handle_minidriver_string(ext, irp, HID_STRING_ID_IMANUFACTURER); + handle_minidriver_string( ext, irp, HID_STRING_ID_IMANUFACTURER ); break; } case IOCTL_HID_GET_COLLECTION_INFORMATION: { - rc = handle_IOCTL_HID_GET_COLLECTION_INFORMATION(irp, ext); + handle_IOCTL_HID_GET_COLLECTION_INFORMATION( irp, ext ); break; } case IOCTL_HID_GET_COLLECTION_DESCRIPTOR: { - rc = handle_IOCTL_HID_GET_COLLECTION_DESCRIPTOR(irp, ext); + handle_IOCTL_HID_GET_COLLECTION_DESCRIPTOR( irp, ext ); break; } case IOCTL_HID_GET_INPUT_REPORT: @@ -529,15 +514,14 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp) packet->reportBuffer = (BYTE *)packet + sizeof(*packet); packet->reportBufferLen = irpsp->Parameters.DeviceIoControl.OutputBufferLength - 1;
- rc = call_minidriver(IOCTL_HID_GET_INPUT_REPORT, ext->u.pdo.parent_fdo, NULL, 0, packet, sizeof(*packet)); - if (rc == STATUS_SUCCESS) + irp->IoStatus.Status = call_minidriver( IOCTL_HID_GET_INPUT_REPORT, ext->u.pdo.parent_fdo, NULL, 0, packet, sizeof(*packet) ); + if (irp->IoStatus.Status == STATUS_SUCCESS) { - rc = copy_packet_into_buffer(packet, buffer, irpsp->Parameters.DeviceIoControl.OutputBufferLength, &out_length); + irp->IoStatus.Status = copy_packet_into_buffer( packet, buffer, irpsp->Parameters.DeviceIoControl.OutputBufferLength, &out_length ); irp->IoStatus.Information = out_length; } else irp->IoStatus.Information = 0; - irp->IoStatus.Status = rc; free(packet); break; } @@ -547,12 +531,11 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp)
if (irpsp->Parameters.DeviceIoControl.InputBufferLength != sizeof(ULONG)) { - irp->IoStatus.Status = rc = STATUS_BUFFER_OVERFLOW; + irp->IoStatus.Status = STATUS_BUFFER_OVERFLOW; } else { - rc = RingBuffer_SetSize(ext->u.pdo.ring_buffer, *(ULONG *)irp->AssociatedIrp.SystemBuffer); - irp->IoStatus.Status = rc; + irp->IoStatus.Status = RingBuffer_SetSize( ext->u.pdo.ring_buffer, *(ULONG *)irp->AssociatedIrp.SystemBuffer ); } break; } @@ -561,22 +544,22 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp) if (irpsp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(ULONG)) { irp->IoStatus.Information = 0; - irp->IoStatus.Status = rc = STATUS_BUFFER_TOO_SMALL; + irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL; } else { *(ULONG *)irp->AssociatedIrp.SystemBuffer = RingBuffer_GetSize(ext->u.pdo.ring_buffer); irp->IoStatus.Information = sizeof(ULONG); - rc = irp->IoStatus.Status = STATUS_SUCCESS; + irp->IoStatus.Status = STATUS_SUCCESS; } break; } case IOCTL_HID_GET_FEATURE: - rc = HID_get_feature(ext, irp); + HID_get_feature( ext, irp ); break; case IOCTL_HID_SET_FEATURE: case IOCTL_HID_SET_OUTPUT_REPORT: - rc = HID_set_to_device(device, irp); + HID_set_to_device( device, irp ); break; default: { @@ -584,15 +567,13 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp) FIXME("Unsupported ioctl %x (device=%x access=%x func=%x method=%x)\n", code, code >> 16, (code >> 14) & 3, (code >> 2) & 0xfff, code & 3); irp->IoStatus.Status = STATUS_NOT_SUPPORTED; - rc = STATUS_UNSUCCESSFUL; break; } }
- if (rc != STATUS_PENDING) - IoCompleteRequest( irp, IO_NO_INCREMENT ); + if (irp->IoStatus.Status != STATUS_PENDING) IoCompleteRequest( irp, IO_NO_INCREMENT );
- return rc; + return irp->IoStatus.Status; }
NTSTATUS WINAPI pdo_read(DEVICE_OBJECT *device, IRP *irp) @@ -601,7 +582,6 @@ NTSTATUS WINAPI pdo_read(DEVICE_OBJECT *device, IRP *irp) BASE_DEVICE_EXTENSION *ext = device->DeviceExtension; const WINE_HIDP_PREPARSED_DATA *data = ext->u.pdo.preparsed_data; UINT buffer_size = RingBuffer_GetBufferSize(ext->u.pdo.ring_buffer); - NTSTATUS rc = STATUS_SUCCESS; IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation(irp); int ptr = -1; BOOL removed; @@ -634,14 +614,12 @@ NTSTATUS WINAPI pdo_read(DEVICE_OBJECT *device, IRP *irp) if (buffer_size) { IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation( irp ); - NTSTATUS rc; ULONG out_length; packet->reportBuffer = (BYTE *)packet + sizeof(*packet); TRACE_(hid_report)("Got Packet %p %i\n", packet->reportBuffer, packet->reportBufferLen);
- rc = copy_packet_into_buffer(packet, irp->AssociatedIrp.SystemBuffer, irpsp->Parameters.Read.Length, &out_length); + irp->IoStatus.Status = copy_packet_into_buffer( packet, irp->AssociatedIrp.SystemBuffer, irpsp->Parameters.Read.Length, &out_length ); irp->IoStatus.Information = out_length; - irp->IoStatus.Status = rc; IoCompleteRequest(irp, IO_NO_INCREMENT); } else @@ -666,7 +644,6 @@ NTSTATUS WINAPI pdo_read(DEVICE_OBJECT *device, IRP *irp) IoMarkIrpPending(irp);
KeReleaseSpinLock(&ext->u.pdo.irp_queue_lock, old_irql); - rc = STATUS_PENDING; } else { @@ -675,20 +652,19 @@ NTSTATUS WINAPI pdo_read(DEVICE_OBJECT *device, IRP *irp) packet.reportId = ((BYTE*)irp->AssociatedIrp.SystemBuffer)[0]; packet.reportBuffer = &((BYTE*)irp->AssociatedIrp.SystemBuffer)[1]; packet.reportBufferLen = irpsp->Parameters.Read.Length - 1; - rc = call_minidriver(IOCTL_HID_GET_INPUT_REPORT, ext->u.pdo.parent_fdo, NULL, 0, &packet, sizeof(packet)); + irp->IoStatus.Status = call_minidriver( IOCTL_HID_GET_INPUT_REPORT, ext->u.pdo.parent_fdo, NULL, 0, &packet, sizeof(packet) );
- if (rc == STATUS_SUCCESS) + if (irp->IoStatus.Status == STATUS_SUCCESS) { ((BYTE*)irp->AssociatedIrp.SystemBuffer)[0] = packet.reportId; irp->IoStatus.Information = packet.reportBufferLen + 1; - irp->IoStatus.Status = rc; } IoCompleteRequest(irp, IO_NO_INCREMENT); } } free(packet);
- return rc; + return irp->IoStatus.Status; }
NTSTATUS WINAPI pdo_write(DEVICE_OBJECT *device, IRP *irp) @@ -699,7 +675,6 @@ NTSTATUS WINAPI pdo_write(DEVICE_OBJECT *device, IRP *irp) HID_XFER_PACKET packet; ULONG max_len; BOOL removed; - NTSTATUS rc; KIRQL irql;
KeAcquireSpinLock(&ext->u.pdo.lock, &irql); @@ -748,18 +723,17 @@ NTSTATUS WINAPI pdo_write(DEVICE_OBJECT *device, IRP *irp)
TRACE_(hid_report)("(id %i, len %i buffer %p)\n", packet.reportId, packet.reportBufferLen, packet.reportBuffer);
- rc = call_minidriver(IOCTL_HID_WRITE_REPORT, ext->u.pdo.parent_fdo, NULL, 0, &packet, sizeof(packet)); + irp->IoStatus.Status = call_minidriver( IOCTL_HID_WRITE_REPORT, ext->u.pdo.parent_fdo, NULL, 0, &packet, sizeof(packet) );
- irp->IoStatus.Status = rc; if (irp->IoStatus.Status == STATUS_SUCCESS) irp->IoStatus.Information = irpsp->Parameters.Write.Length; else irp->IoStatus.Information = 0;
- TRACE_(hid_report)("Result 0x%x wrote %li bytes\n", rc, irp->IoStatus.Information); + TRACE_(hid_report)( "Result 0x%x wrote %li bytes\n", irp->IoStatus.Status, irp->IoStatus.Information );
IoCompleteRequest( irp, IO_NO_INCREMENT ); - return rc; + return irp->IoStatus.Status; }
NTSTATUS WINAPI pdo_create(DEVICE_OBJECT *device, IRP *irp)