- Simplify some loops in USBPORT_OpenInterface. No logical changes
svn path=/trunk/; revision=75907
RtlZeroMemory(InterfaceHandle, HandleLength);
RtlZeroMemory(InterfaceHandle, HandleLength);
+ for (ix = 0; ix < NumEndpoints; ++ix)
- PipeHandle = &InterfaceHandle->PipeHandle[0];
+ PipeHandle = &InterfaceHandle->PipeHandle[ix];
- for (ix = 0; ix < NumEndpoints; ++ix)
- {
- PipeHandle->Flags = PIPE_HANDLE_FLAG_CLOSED;
- PipeHandle->Endpoint = NULL;
-
- PipeHandle += 1;
- }
+ PipeHandle->Flags = PIPE_HANDLE_FLAG_CLOSED;
+ PipeHandle->Endpoint = NULL;
Descriptor = (PUSB_ENDPOINT_DESCRIPTOR)((ULONG_PTR)InterfaceDescriptor +
InterfaceDescriptor->bLength);
Descriptor = (PUSB_ENDPOINT_DESCRIPTOR)((ULONG_PTR)InterfaceDescriptor +
InterfaceDescriptor->bLength);
+ for (ix = 0; ix < NumEndpoints; ++ix)
- PipeHandle = &InterfaceHandle->PipeHandle[0];
+ PipeHandle = &InterfaceHandle->PipeHandle[ix];
- for (ix = 0; ix < NumEndpoints; ++ix)
+ while (Descriptor->bDescriptorType != USB_ENDPOINT_DESCRIPTOR_TYPE)
- while (Descriptor->bDescriptorType != USB_ENDPOINT_DESCRIPTOR_TYPE)
+ if (Descriptor->bLength == 0)
- 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;
+ Descriptor = (PUSB_ENDPOINT_DESCRIPTOR)((ULONG_PTR)Descriptor +
+ Descriptor->bLength);
- RtlCopyMemory(&PipeHandle->EndpointDescriptor,
- Descriptor,
- sizeof(USB_ENDPOINT_DESCRIPTOR));
+ if (InterfaceInfo->Pipes[ix].PipeFlags & USBD_PF_CHANGE_MAX_PACKET)
+ {
+ Descriptor->wMaxPacketSize = InterfaceInfo->Pipes[ix].MaximumPacketSize;
+ }
- PipeHandle->Flags = PIPE_HANDLE_FLAG_CLOSED;
- PipeHandle->PipeFlags = InterfaceInfo->Pipes[ix].PipeFlags;
- PipeHandle->Endpoint = NULL;
+ RtlCopyMemory(&PipeHandle->EndpointDescriptor,
+ Descriptor,
+ sizeof(USB_ENDPOINT_DESCRIPTOR));
- wMaxPacketSize = Descriptor->wMaxPacketSize;
+ PipeHandle->Flags = PIPE_HANDLE_FLAG_CLOSED;
+ PipeHandle->PipeFlags = InterfaceInfo->Pipes[ix].PipeFlags;
+ PipeHandle->Endpoint = NULL;
- /* USB 2.0 Specification, 5.9 High-Speed, High Bandwidth Endpoints */
- MaxPacketSize = (wMaxPacketSize & 0x7FF) * (((wMaxPacketSize >> 11) & 3) + 1);
+ wMaxPacketSize = Descriptor->wMaxPacketSize;
- 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;
+ /* USB 2.0 Specification, 5.9 High-Speed, High Bandwidth Endpoints */
+ MaxPacketSize = (wMaxPacketSize & 0x7FF) * (((wMaxPacketSize >> 11) & 3) + 1);
- Descriptor = (PUSB_ENDPOINT_DESCRIPTOR)((ULONG_PTR)Descriptor +
- Descriptor->bLength);
+ 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))
{
}
if (USBD_SUCCESS(USBDStatus))
{
+ for (ix = 0; ix < NumEndpoints; ++ix)
- PipeInfo = &InterfaceInfo->Pipes[0];
- PipeHandle = &InterfaceHandle->PipeHandle[0];
-
- for (ix = 0; ix < NumEndpoints; ++ix)
- {
- Status = USBPORT_OpenPipe(FdoDevice,
- DeviceHandle,
- PipeHandle,
- &USBDStatus);
+ PipeInfo = &InterfaceInfo->Pipes[ix];
+ PipeHandle = &InterfaceHandle->PipeHandle[ix];
- if (!NT_SUCCESS(Status))
- break;
+ Status = USBPORT_OpenPipe(FdoDevice,
+ DeviceHandle,
+ PipeHandle,
+ &USBDStatus);
- PipeInfo->PipeHandle = PipeHandle;
+ if (!NT_SUCCESS(Status))
+ break;
- PipeHandle += 1;
- PipeInfo += 1;
- }
+ PipeInfo->PipeHandle = PipeHandle;
+ }
USBPORT_USBDStatusToNtStatus(Urb, USBDStatus);
}
}
USBPORT_USBDStatusToNtStatus(Urb, USBDStatus);
}
}
PipeHandleList = PipeHandleList->Flink;
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;
USBPORT_EndpointHasQueuedTransfers(FdoDevice, PipeHandle->Endpoint, NULL))
{
return TRUE;