https://git.reactos.org/?p=reactos.git;a=commitdiff;h=73bfc3c8979d9127a7dd8214ea9b954cd13e39df

commit 73bfc3c8979d9127a7dd8214ea9b954cd13e39df
Author: Vadim Galyant <v...@rambler.ru>
AuthorDate: Thu Nov 23 20:14:06 2017 +0900

    [USBPORT] Type-safe function signature (PVOID -> PUSBPORT_xxx).
---
 drivers/usb/usbport/device.c                   |   4 +-
 drivers/usb/usbport/endpoint.c                 |  22 ++--
 drivers/usb/usbport/roothub.c                  |   4 +-
 drivers/usb/usbport/usbport.h                  |   4 +-
 sdk/include/reactos/drivers/usbport/usbmport.h | 139 +++++++++++++------------
 5 files changed, 89 insertions(+), 84 deletions(-)

diff --git a/drivers/usb/usbport/device.c b/drivers/usb/usbport/device.c
index b9063a70bd..f7180aaf96 100644
--- a/drivers/usb/usbport/device.c
+++ b/drivers/usb/usbport/device.c
@@ -1524,7 +1524,7 @@ USBPORT_RestoreDevice(IN PDEVICE_OBJECT FdoDevice,
     PUSBPORT_DEVICE_EXTENSION  FdoExtension;
     PLIST_ENTRY iHandleList;
     PUSBPORT_ENDPOINT Endpoint;
-    ULONG EndpointRequirements[2] = {0};
+    USBPORT_ENDPOINT_REQUIREMENTS EndpointRequirements = {0};
     USB_DEFAULT_PIPE_SETUP_PACKET SetupPacket;
     NTSTATUS Status = STATUS_SUCCESS;
     USBD_STATUS USBDStatus;
@@ -1707,7 +1707,7 @@ USBPORT_RestoreDevice(IN PDEVICE_OBJECT FdoDevice,
 
                         
Packet->QueryEndpointRequirements(FdoExtension->MiniPortExt,
                                                           
&Endpoint->EndpointProperties,
-                                                          
EndpointRequirements);
+                                                          
&EndpointRequirements);
 
                         KeReleaseSpinLock(&FdoExtension->MiniportSpinLock,
                                           OldIrql);
diff --git a/drivers/usb/usbport/endpoint.c b/drivers/usb/usbport/endpoint.c
index f933922e8b..7cf250e76c 100644
--- a/drivers/usb/usbport/endpoint.c
+++ b/drivers/usb/usbport/endpoint.c
@@ -620,7 +620,7 @@ USBPORT_OpenPipe(IN PDEVICE_OBJECT FdoDevice,
     UCHAR Direction;
     UCHAR Interval;
     UCHAR Period;
-    ULONG TransferParams[2] = {0};
+    USBPORT_ENDPOINT_REQUIREMENTS EndpointRequirements = {0};
     PUSBPORT_COMMON_BUFFER_HEADER HeaderBuffer;
     MPSTATUS MpStatus;
     USBD_STATUS USBDStatus;
@@ -832,27 +832,27 @@ USBPORT_OpenPipe(IN PDEVICE_OBJECT FdoDevice,
 
         Packet->QueryEndpointRequirements(FdoExtension->MiniPortExt,
                                           &Endpoint->EndpointProperties,
-                                          TransferParams);
+                                          &EndpointRequirements);
 
         KeReleaseSpinLock(&FdoExtension->MiniportSpinLock, OldIrql);
 
         if ((EndpointProperties->TransferType == USBPORT_TRANSFER_TYPE_BULK) ||
             (EndpointProperties->TransferType == 
USBPORT_TRANSFER_TYPE_INTERRUPT))
         {
-            EndpointProperties->MaxTransferSize = TransferParams[1];
+            EndpointProperties->MaxTransferSize = 
EndpointRequirements.MaxTransferSize;
         }
 
-        if (TransferParams[0])
+        if (EndpointRequirements.HeaderBufferSize)
         {
             HeaderBuffer = USBPORT_AllocateCommonBuffer(FdoDevice,
-                                                        TransferParams[0]);
+                                                        
EndpointRequirements.HeaderBufferSize);
         }
         else
         {
             HeaderBuffer = NULL;
         }
 
-        if (HeaderBuffer || (TransferParams[0] == 0))
+        if (HeaderBuffer || (EndpointRequirements.HeaderBufferSize == 0))
         {
             Endpoint->HeaderBuffer = HeaderBuffer;
 
@@ -969,7 +969,7 @@ USBPORT_ReopenPipe(IN PDEVICE_OBJECT FdoDevice,
 {
     PUSBPORT_DEVICE_EXTENSION FdoExtension;
     PUSBPORT_COMMON_BUFFER_HEADER HeaderBuffer;
-    ULONG EndpointRequirements[2] = {0};
+    USBPORT_ENDPOINT_REQUIREMENTS EndpointRequirements = {0};
     PUSBPORT_REGISTRATION_PACKET Packet;
     KIRQL MiniportOldIrql;
     NTSTATUS Status;
@@ -1013,21 +1013,21 @@ USBPORT_ReopenPipe(IN PDEVICE_OBJECT FdoDevice,
 
     Packet->QueryEndpointRequirements(FdoExtension->MiniPortExt,
                                       &Endpoint->EndpointProperties,
-                                      EndpointRequirements);
+                                      &EndpointRequirements);
 
     KeReleaseSpinLock(&FdoExtension->MiniportSpinLock, MiniportOldIrql);
 
-    if (EndpointRequirements[0])
+    if (EndpointRequirements.HeaderBufferSize)
     {
         HeaderBuffer = USBPORT_AllocateCommonBuffer(FdoDevice,
-                                                    EndpointRequirements[0]);
+                                                    
EndpointRequirements.HeaderBufferSize);
     }
     else
     {
         HeaderBuffer = NULL;
     }
 
-    if (HeaderBuffer || EndpointRequirements[0] == 0)
+    if (HeaderBuffer || EndpointRequirements.HeaderBufferSize == 0)
     {
         Endpoint->HeaderBuffer = HeaderBuffer;
         Status = STATUS_SUCCESS;
diff --git a/drivers/usb/usbport/roothub.c b/drivers/usb/usbport/roothub.c
index c5a77aef51..f843afd83a 100644
--- a/drivers/usb/usbport/roothub.c
+++ b/drivers/usb/usbport/roothub.c
@@ -170,7 +170,7 @@ USBPORT_RootHubClassCommand(IN PDEVICE_OBJECT FdoDevice,
         case USB_REQUEST_CLEAR_FEATURE:
             Feature = SetupPacket->wValue.W;
 
-            if ((SetupPacket->bmRequestType.Recipient) != 
USBPORT_RECIPIENT_ROOT_PORT)
+            if ((SetupPacket->bmRequestType.Recipient) != 
USBPORT_RECIPIENT_PORT)
             {
                 if (Feature == FEATURE_C_HUB_LOCAL_POWER)
                 {
@@ -242,7 +242,7 @@ USBPORT_RootHubClassCommand(IN PDEVICE_OBJECT FdoDevice,
             break;
 
         case USB_REQUEST_SET_FEATURE:
-            if (SetupPacket->bmRequestType.Recipient != 
USBPORT_RECIPIENT_ROOT_PORT)
+            if (SetupPacket->bmRequestType.Recipient != USBPORT_RECIPIENT_PORT)
             {
                 return RHStatus;
             }
diff --git a/drivers/usb/usbport/usbport.h b/drivers/usb/usbport/usbport.h
index aca072b88d..26e021cb14 100644
--- a/drivers/usb/usbport/usbport.h
+++ b/drivers/usb/usbport/usbport.h
@@ -30,8 +30,8 @@
 #define USBD_TRANSFER_DIRECTION 0x00000001
 #endif
 
-#define USBPORT_RECIPIENT_ROOT_HUB  BMREQUEST_TO_DEVICE
-#define USBPORT_RECIPIENT_ROOT_PORT BMREQUEST_TO_OTHER
+#define USBPORT_RECIPIENT_HUB  BMREQUEST_TO_DEVICE
+#define USBPORT_RECIPIENT_PORT BMREQUEST_TO_OTHER
 
 #define INVALIDATE_ENDPOINT_ONLY           0
 #define INVALIDATE_ENDPOINT_WORKER_THREAD  1
diff --git a/sdk/include/reactos/drivers/usbport/usbmport.h 
b/sdk/include/reactos/drivers/usbport/usbmport.h
index 2b14bac56a..23a7e91e9a 100644
--- a/sdk/include/reactos/drivers/usbport/usbmport.h
+++ b/sdk/include/reactos/drivers/usbport/usbmport.h
@@ -64,6 +64,70 @@ typedef struct _USBPORT_RESOURCES {
 
 C_ASSERT(sizeof(USBPORT_RESOURCES) == 24 + 7 * sizeof(PVOID));
 
+typedef struct _USBPORT_ENDPOINT_PROPERTIES {
+  USHORT DeviceAddress;
+  USHORT EndpointAddress;
+  USHORT TotalMaxPacketSize; // TransactionPerMicroframe * MaxPacketSize
+  UCHAR Period;
+  UCHAR Reserved1;
+  USB_DEVICE_SPEED DeviceSpeed;
+  ULONG UsbBandwidth;
+  ULONG ScheduleOffset;
+  ULONG TransferType;
+  ULONG Direction;
+  ULONG_PTR BufferVA;
+  ULONG_PTR BufferPA;
+  ULONG BufferLength;
+  ULONG Reserved3;
+  ULONG MaxTransferSize;
+  USHORT HubAddr;
+  USHORT PortNumber;
+  UCHAR InterruptScheduleMask;
+  UCHAR SplitCompletionMask;
+  UCHAR TransactionPerMicroframe; // 1 + additional transactions. Total: from 
1 to 3)
+  UCHAR Reserved4;
+  ULONG MaxPacketSize;
+  ULONG Reserved6;
+} USBPORT_ENDPOINT_PROPERTIES, *PUSBPORT_ENDPOINT_PROPERTIES;
+
+C_ASSERT(sizeof(USBPORT_ENDPOINT_PROPERTIES) == 48 + 4 * sizeof(PVOID));
+
+typedef struct _USBPORT_TRANSFER_PARAMETERS {
+  ULONG TransferFlags;
+  ULONG TransferBufferLength;
+  ULONG TransferCounter;
+  BOOL IsTransferSplited;
+  ULONG Reserved2;
+  USB_DEFAULT_PIPE_SETUP_PACKET SetupPacket;
+} USBPORT_TRANSFER_PARAMETERS, *PUSBPORT_TRANSFER_PARAMETERS;
+
+C_ASSERT(sizeof(USBPORT_TRANSFER_PARAMETERS) == 28);
+
+typedef struct _USBPORT_SCATTER_GATHER_ELEMENT {
+  PHYSICAL_ADDRESS SgPhysicalAddress;
+  ULONG Reserved1;
+  ULONG SgTransferLength;
+  ULONG SgOffset;
+  ULONG Reserved2;
+} USBPORT_SCATTER_GATHER_ELEMENT, *PUSBPORT_SCATTER_GATHER_ELEMENT;
+
+C_ASSERT(sizeof(USBPORT_SCATTER_GATHER_ELEMENT) == 24);
+
+typedef struct _USBPORT_SCATTER_GATHER_LIST {
+  ULONG Flags;
+  ULONG_PTR CurrentVa;
+  PVOID MappedSystemVa;
+  ULONG SgElementCount;
+  USBPORT_SCATTER_GATHER_ELEMENT SgElement[2];
+} USBPORT_SCATTER_GATHER_LIST, *PUSBPORT_SCATTER_GATHER_LIST;
+
+C_ASSERT(sizeof(USBPORT_SCATTER_GATHER_LIST) == 48 + 4 * sizeof(PVOID));
+
+typedef struct _USBPORT_ENDPOINT_REQUIREMENTS {
+  ULONG HeaderBufferSize;
+  ULONG MaxTransferSize;
+} USBPORT_ENDPOINT_REQUIREMENTS, *PUSBPORT_ENDPOINT_REQUIREMENTS;
+
 typedef ULONG MPSTATUS; // Miniport status
 typedef ULONG RHSTATUS; // Roothub status
 
@@ -88,20 +152,20 @@ typedef ULONG RHSTATUS; // Roothub status
 typedef MPSTATUS
 (NTAPI *PHCI_OPEN_ENDPOINT)(
   PVOID,
-  PVOID,
+  PUSBPORT_ENDPOINT_PROPERTIES,
   PVOID);
 
 typedef MPSTATUS
 (NTAPI *PHCI_REOPEN_ENDPOINT)(
   PVOID,
-  PVOID,
+  PUSBPORT_ENDPOINT_PROPERTIES,
   PVOID);
 
 typedef VOID
 (NTAPI *PHCI_QUERY_ENDPOINT_REQUIREMENTS)(
   PVOID,
-  PVOID,
-  PULONG);
+  PUSBPORT_ENDPOINT_PROPERTIES,
+  PUSBPORT_ENDPOINT_REQUIREMENTS);
 
 typedef VOID
 (NTAPI *PHCI_CLOSE_ENDPOINT)(
@@ -137,15 +201,15 @@ typedef MPSTATUS
 (NTAPI *PHCI_SUBMIT_TRANSFER)(
   PVOID,
   PVOID,
+  PUSBPORT_TRANSFER_PARAMETERS,
   PVOID,
-  PVOID,
-  PVOID);
+  PUSBPORT_SCATTER_GATHER_LIST);
 
 typedef MPSTATUS
 (NTAPI *PHCI_SUBMIT_ISO_TRANSFER)(
   PVOID,
   PVOID,
-  PVOID,
+  PUSBPORT_TRANSFER_PARAMETERS,
   PVOID,
   PVOID);
 
@@ -443,7 +507,7 @@ typedef ULONG
 typedef VOID
 (NTAPI *PHCI_REBALANCE_ENDPOINT)(
   PVOID,
-  PVOID,
+  PUSBPORT_ENDPOINT_PROPERTIES,
   PVOID);
 
 typedef VOID
@@ -583,65 +647,6 @@ C_ASSERT(sizeof(USBPORT_MINIPORT_INTERFACE) == 32 + 76 * 
sizeof(PVOID));
 #define USBPORT_TRANSFER_DIRECTION_OUT  1 // From host to device
 #define USBPORT_MAX_DEVICE_ADDRESS      127
 
-typedef struct _USBPORT_ENDPOINT_PROPERTIES {
-  USHORT DeviceAddress;
-  USHORT EndpointAddress;
-  USHORT TotalMaxPacketSize; // TransactionPerMicroframe * MaxPacketSize
-  UCHAR Period;
-  UCHAR Reserved1;
-  USB_DEVICE_SPEED DeviceSpeed;
-  ULONG UsbBandwidth;
-  ULONG ScheduleOffset;
-  ULONG TransferType;
-  ULONG Direction;
-  ULONG_PTR BufferVA;
-  ULONG_PTR BufferPA;
-  ULONG BufferLength;
-  ULONG Reserved3;
-  ULONG MaxTransferSize;
-  USHORT HubAddr;
-  USHORT PortNumber;
-  UCHAR InterruptScheduleMask;
-  UCHAR SplitCompletionMask;
-  UCHAR TransactionPerMicroframe; // 1 + additional transactions. Total: from 
1 to 3)
-  UCHAR Reserved4;
-  ULONG MaxPacketSize;
-  ULONG Reserved6;
-} USBPORT_ENDPOINT_PROPERTIES, *PUSBPORT_ENDPOINT_PROPERTIES;
-
-C_ASSERT(sizeof(USBPORT_ENDPOINT_PROPERTIES) == 48 + 4 * sizeof(PVOID));
-
-typedef struct _USBPORT_SCATTER_GATHER_ELEMENT {
-  PHYSICAL_ADDRESS SgPhysicalAddress;
-  ULONG Reserved1;
-  ULONG SgTransferLength;
-  ULONG SgOffset;
-  ULONG Reserved2;
-} USBPORT_SCATTER_GATHER_ELEMENT, *PUSBPORT_SCATTER_GATHER_ELEMENT;
-
-C_ASSERT(sizeof(USBPORT_SCATTER_GATHER_ELEMENT) == 24);
-
-typedef struct _USBPORT_SCATTER_GATHER_LIST {
-  ULONG Flags;
-  ULONG_PTR CurrentVa;
-  PVOID MappedSystemVa;
-  ULONG SgElementCount;
-  USBPORT_SCATTER_GATHER_ELEMENT SgElement[2];
-} USBPORT_SCATTER_GATHER_LIST, *PUSBPORT_SCATTER_GATHER_LIST;
-
-C_ASSERT(sizeof(USBPORT_SCATTER_GATHER_LIST) == 48 + 4 * sizeof(PVOID));
-
-typedef struct _USBPORT_TRANSFER_PARAMETERS {
-  ULONG TransferFlags;
-  ULONG TransferBufferLength;
-  ULONG TransferCounter;
-  BOOL IsTransferSplited;
-  ULONG Reserved2;
-  USB_DEFAULT_PIPE_SETUP_PACKET SetupPacket;
-} USBPORT_TRANSFER_PARAMETERS, *PUSBPORT_TRANSFER_PARAMETERS;
-
-C_ASSERT(sizeof(USBPORT_TRANSFER_PARAMETERS) == 28);
-
 /* For USB1.1 or USB3 Hub Descriptors */
 typedef union _USBPORT_HUB_11_CHARACTERISTICS {
   struct {

Reply via email to