Author: tfaber Date: Mon Sep 18 12:01:12 2017 New Revision: 75907
URL: http://svn.reactos.org/svn/reactos?rev=75907&view=rev Log: [USBPORT] - Simplify some loops in USBPORT_OpenInterface. No logical changes
Modified: trunk/reactos/drivers/usb/usbport/device.c
Modified: trunk/reactos/drivers/usb/usbport/device.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbport/device.... ============================================================================== --- trunk/reactos/drivers/usb/usbport/device.c [iso-8859-1] (original) +++ trunk/reactos/drivers/usb/usbport/device.c [iso-8859-1] Mon Sep 18 12:01:12 2017 @@ -304,17 +304,12 @@
RtlZeroMemory(InterfaceHandle, HandleLength);
- if (NumEndpoints > 0) - { - PipeHandle = &InterfaceHandle->PipeHandle[0]; - - for (ix = 0; ix < NumEndpoints; ++ix) - { - PipeHandle->Flags = PIPE_HANDLE_FLAG_CLOSED; - PipeHandle->Endpoint = NULL; - - PipeHandle += 1; - } + for (ix = 0; ix < NumEndpoints; ++ix) + { + PipeHandle = &InterfaceHandle->PipeHandle[ix]; + + PipeHandle->Flags = PIPE_HANDLE_FLAG_CLOSED; + PipeHandle->Endpoint = NULL; }
IsAllocated = TRUE; @@ -335,79 +330,71 @@ Descriptor = (PUSB_ENDPOINT_DESCRIPTOR)((ULONG_PTR)InterfaceDescriptor + InterfaceDescriptor->bLength);
- if (NumEndpoints) - { - PipeHandle = &InterfaceHandle->PipeHandle[0]; - + for (ix = 0; ix < NumEndpoints; ++ix) + { + PipeHandle = &InterfaceHandle->PipeHandle[ix]; + + while (Descriptor->bDescriptorType != USB_ENDPOINT_DESCRIPTOR_TYPE) + { + if (Descriptor->bLength == 0) + { + break; + } + else + { + Descriptor = (PUSB_ENDPOINT_DESCRIPTOR)((ULONG_PTR)Descriptor + + Descriptor->bLength); + } + } + + if (InterfaceInfo->Pipes[ix].PipeFlags & USBD_PF_CHANGE_MAX_PACKET) + { + Descriptor->wMaxPacketSize = InterfaceInfo->Pipes[ix].MaximumPacketSize; + } + + RtlCopyMemory(&PipeHandle->EndpointDescriptor, + Descriptor, + sizeof(USB_ENDPOINT_DESCRIPTOR)); + + PipeHandle->Flags = PIPE_HANDLE_FLAG_CLOSED; + PipeHandle->PipeFlags = InterfaceInfo->Pipes[ix].PipeFlags; + PipeHandle->Endpoint = NULL; + + wMaxPacketSize = Descriptor->wMaxPacketSize; + + /* USB 2.0 Specification, 5.9 High-Speed, High Bandwidth Endpoints */ + MaxPacketSize = (wMaxPacketSize & 0x7FF) * (((wMaxPacketSize >> 11) & 3) + 1); + + InterfaceInfo->Pipes[ix].EndpointAddress = Descriptor->bEndpointAddress; + InterfaceInfo->Pipes[ix].PipeType = Descriptor->bmAttributes & USB_ENDPOINT_TYPE_MASK; + InterfaceInfo->Pipes[ix].MaximumPacketSize = MaxPacketSize; + InterfaceInfo->Pipes[ix].PipeHandle = (USBD_PIPE_HANDLE)-1; + InterfaceInfo->Pipes[ix].Interval = Descriptor->bInterval; + + Descriptor = (PUSB_ENDPOINT_DESCRIPTOR)((ULONG_PTR)Descriptor + + Descriptor->bLength); + } + + if (USBD_SUCCESS(USBDStatus)) + { for (ix = 0; ix < NumEndpoints; ++ix) { - while (Descriptor->bDescriptorType != USB_ENDPOINT_DESCRIPTOR_TYPE) - { - if (Descriptor->bLength == 0) - { - break; - } - else - { - Descriptor = (PUSB_ENDPOINT_DESCRIPTOR)((ULONG_PTR)Descriptor + - Descriptor->bLength); - } - } - - if (InterfaceInfo->Pipes[ix].PipeFlags & USBD_PF_CHANGE_MAX_PACKET) - { - Descriptor->wMaxPacketSize = InterfaceInfo->Pipes[ix].MaximumPacketSize; - } - - RtlCopyMemory(&PipeHandle->EndpointDescriptor, - Descriptor, - sizeof(USB_ENDPOINT_DESCRIPTOR)); - - PipeHandle->Flags = PIPE_HANDLE_FLAG_CLOSED; - PipeHandle->PipeFlags = InterfaceInfo->Pipes[ix].PipeFlags; - PipeHandle->Endpoint = NULL; - - wMaxPacketSize = Descriptor->wMaxPacketSize; - - /* USB 2.0 Specification, 5.9 High-Speed, High Bandwidth Endpoints */ - MaxPacketSize = (wMaxPacketSize & 0x7FF) * (((wMaxPacketSize >> 11) & 3) + 1); - - InterfaceInfo->Pipes[ix].EndpointAddress = Descriptor->bEndpointAddress; - InterfaceInfo->Pipes[ix].PipeType = Descriptor->bmAttributes & USB_ENDPOINT_TYPE_MASK; - InterfaceInfo->Pipes[ix].MaximumPacketSize = MaxPacketSize; - InterfaceInfo->Pipes[ix].PipeHandle = (USBD_PIPE_HANDLE)-1; - InterfaceInfo->Pipes[ix].Interval = Descriptor->bInterval; - - Descriptor = (PUSB_ENDPOINT_DESCRIPTOR)((ULONG_PTR)Descriptor + - Descriptor->bLength); - - PipeHandle += 1; - } - } - - if (USBD_SUCCESS(USBDStatus)) - { + PipeInfo = &InterfaceInfo->Pipes[ix]; + PipeHandle = &InterfaceHandle->PipeHandle[ix]; + + Status = USBPORT_OpenPipe(FdoDevice, + DeviceHandle, + PipeHandle, + &USBDStatus); + + if (!NT_SUCCESS(Status)) + break; + + PipeInfo->PipeHandle = PipeHandle; + } + if (NumEndpoints) { - PipeInfo = &InterfaceInfo->Pipes[0]; - PipeHandle = &InterfaceHandle->PipeHandle[0]; - - for (ix = 0; ix < NumEndpoints; ++ix) - { - Status = USBPORT_OpenPipe(FdoDevice, - DeviceHandle, - PipeHandle, - &USBDStatus); - - if (!NT_SUCCESS(Status)) - break; - - PipeInfo->PipeHandle = PipeHandle; - - PipeHandle += 1; - PipeInfo += 1; - } - USBPORT_USBDStatusToNtStatus(Urb, USBDStatus); } } @@ -847,7 +834,7 @@
PipeHandleList = PipeHandleList->Flink;
- if (!(PipeHandle->Flags & PIPE_HANDLE_FLAG_NULL_PACKET_SIZE) && + if (!(PipeHandle->Flags & PIPE_HANDLE_FLAG_NULL_PACKET_SIZE) && USBPORT_EndpointHasQueuedTransfers(FdoDevice, PipeHandle->Endpoint, NULL)) { return TRUE;