Skip to content

Commit 73bfc3c

Browse files
vgalntThFabba
authored andcommitted
[USBPORT] Type-safe function signature (PVOID -> PUSBPORT_xxx).
1 parent a913501 commit 73bfc3c

File tree

5 files changed

+89
-84
lines changed

5 files changed

+89
-84
lines changed

drivers/usb/usbport/device.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,7 +1524,7 @@ USBPORT_RestoreDevice(IN PDEVICE_OBJECT FdoDevice,
15241524
PUSBPORT_DEVICE_EXTENSION FdoExtension;
15251525
PLIST_ENTRY iHandleList;
15261526
PUSBPORT_ENDPOINT Endpoint;
1527-
ULONG EndpointRequirements[2] = {0};
1527+
USBPORT_ENDPOINT_REQUIREMENTS EndpointRequirements = {0};
15281528
USB_DEFAULT_PIPE_SETUP_PACKET SetupPacket;
15291529
NTSTATUS Status = STATUS_SUCCESS;
15301530
USBD_STATUS USBDStatus;
@@ -1707,7 +1707,7 @@ USBPORT_RestoreDevice(IN PDEVICE_OBJECT FdoDevice,
17071707

17081708
Packet->QueryEndpointRequirements(FdoExtension->MiniPortExt,
17091709
&Endpoint->EndpointProperties,
1710-
EndpointRequirements);
1710+
&EndpointRequirements);
17111711

17121712
KeReleaseSpinLock(&FdoExtension->MiniportSpinLock,
17131713
OldIrql);

drivers/usb/usbport/endpoint.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ USBPORT_OpenPipe(IN PDEVICE_OBJECT FdoDevice,
620620
UCHAR Direction;
621621
UCHAR Interval;
622622
UCHAR Period;
623-
ULONG TransferParams[2] = {0};
623+
USBPORT_ENDPOINT_REQUIREMENTS EndpointRequirements = {0};
624624
PUSBPORT_COMMON_BUFFER_HEADER HeaderBuffer;
625625
MPSTATUS MpStatus;
626626
USBD_STATUS USBDStatus;
@@ -832,27 +832,27 @@ USBPORT_OpenPipe(IN PDEVICE_OBJECT FdoDevice,
832832

833833
Packet->QueryEndpointRequirements(FdoExtension->MiniPortExt,
834834
&Endpoint->EndpointProperties,
835-
TransferParams);
835+
&EndpointRequirements);
836836

837837
KeReleaseSpinLock(&FdoExtension->MiniportSpinLock, OldIrql);
838838

839839
if ((EndpointProperties->TransferType == USBPORT_TRANSFER_TYPE_BULK) ||
840840
(EndpointProperties->TransferType == USBPORT_TRANSFER_TYPE_INTERRUPT))
841841
{
842-
EndpointProperties->MaxTransferSize = TransferParams[1];
842+
EndpointProperties->MaxTransferSize = EndpointRequirements.MaxTransferSize;
843843
}
844844

845-
if (TransferParams[0])
845+
if (EndpointRequirements.HeaderBufferSize)
846846
{
847847
HeaderBuffer = USBPORT_AllocateCommonBuffer(FdoDevice,
848-
TransferParams[0]);
848+
EndpointRequirements.HeaderBufferSize);
849849
}
850850
else
851851
{
852852
HeaderBuffer = NULL;
853853
}
854854

855-
if (HeaderBuffer || (TransferParams[0] == 0))
855+
if (HeaderBuffer || (EndpointRequirements.HeaderBufferSize == 0))
856856
{
857857
Endpoint->HeaderBuffer = HeaderBuffer;
858858

@@ -969,7 +969,7 @@ USBPORT_ReopenPipe(IN PDEVICE_OBJECT FdoDevice,
969969
{
970970
PUSBPORT_DEVICE_EXTENSION FdoExtension;
971971
PUSBPORT_COMMON_BUFFER_HEADER HeaderBuffer;
972-
ULONG EndpointRequirements[2] = {0};
972+
USBPORT_ENDPOINT_REQUIREMENTS EndpointRequirements = {0};
973973
PUSBPORT_REGISTRATION_PACKET Packet;
974974
KIRQL MiniportOldIrql;
975975
NTSTATUS Status;
@@ -1013,21 +1013,21 @@ USBPORT_ReopenPipe(IN PDEVICE_OBJECT FdoDevice,
10131013

10141014
Packet->QueryEndpointRequirements(FdoExtension->MiniPortExt,
10151015
&Endpoint->EndpointProperties,
1016-
EndpointRequirements);
1016+
&EndpointRequirements);
10171017

10181018
KeReleaseSpinLock(&FdoExtension->MiniportSpinLock, MiniportOldIrql);
10191019

1020-
if (EndpointRequirements[0])
1020+
if (EndpointRequirements.HeaderBufferSize)
10211021
{
10221022
HeaderBuffer = USBPORT_AllocateCommonBuffer(FdoDevice,
1023-
EndpointRequirements[0]);
1023+
EndpointRequirements.HeaderBufferSize);
10241024
}
10251025
else
10261026
{
10271027
HeaderBuffer = NULL;
10281028
}
10291029

1030-
if (HeaderBuffer || EndpointRequirements[0] == 0)
1030+
if (HeaderBuffer || EndpointRequirements.HeaderBufferSize == 0)
10311031
{
10321032
Endpoint->HeaderBuffer = HeaderBuffer;
10331033
Status = STATUS_SUCCESS;

drivers/usb/usbport/roothub.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ USBPORT_RootHubClassCommand(IN PDEVICE_OBJECT FdoDevice,
170170
case USB_REQUEST_CLEAR_FEATURE:
171171
Feature = SetupPacket->wValue.W;
172172

173-
if ((SetupPacket->bmRequestType.Recipient) != USBPORT_RECIPIENT_ROOT_PORT)
173+
if ((SetupPacket->bmRequestType.Recipient) != USBPORT_RECIPIENT_PORT)
174174
{
175175
if (Feature == FEATURE_C_HUB_LOCAL_POWER)
176176
{
@@ -242,7 +242,7 @@ USBPORT_RootHubClassCommand(IN PDEVICE_OBJECT FdoDevice,
242242
break;
243243

244244
case USB_REQUEST_SET_FEATURE:
245-
if (SetupPacket->bmRequestType.Recipient != USBPORT_RECIPIENT_ROOT_PORT)
245+
if (SetupPacket->bmRequestType.Recipient != USBPORT_RECIPIENT_PORT)
246246
{
247247
return RHStatus;
248248
}

drivers/usb/usbport/usbport.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
#define USBD_TRANSFER_DIRECTION 0x00000001
3131
#endif
3232

33-
#define USBPORT_RECIPIENT_ROOT_HUB BMREQUEST_TO_DEVICE
34-
#define USBPORT_RECIPIENT_ROOT_PORT BMREQUEST_TO_OTHER
33+
#define USBPORT_RECIPIENT_HUB BMREQUEST_TO_DEVICE
34+
#define USBPORT_RECIPIENT_PORT BMREQUEST_TO_OTHER
3535

3636
#define INVALIDATE_ENDPOINT_ONLY 0
3737
#define INVALIDATE_ENDPOINT_WORKER_THREAD 1

sdk/include/reactos/drivers/usbport/usbmport.h

Lines changed: 72 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,70 @@ typedef struct _USBPORT_RESOURCES {
6464

6565
C_ASSERT(sizeof(USBPORT_RESOURCES) == 24 + 7 * sizeof(PVOID));
6666

67+
typedef struct _USBPORT_ENDPOINT_PROPERTIES {
68+
USHORT DeviceAddress;
69+
USHORT EndpointAddress;
70+
USHORT TotalMaxPacketSize; // TransactionPerMicroframe * MaxPacketSize
71+
UCHAR Period;
72+
UCHAR Reserved1;
73+
USB_DEVICE_SPEED DeviceSpeed;
74+
ULONG UsbBandwidth;
75+
ULONG ScheduleOffset;
76+
ULONG TransferType;
77+
ULONG Direction;
78+
ULONG_PTR BufferVA;
79+
ULONG_PTR BufferPA;
80+
ULONG BufferLength;
81+
ULONG Reserved3;
82+
ULONG MaxTransferSize;
83+
USHORT HubAddr;
84+
USHORT PortNumber;
85+
UCHAR InterruptScheduleMask;
86+
UCHAR SplitCompletionMask;
87+
UCHAR TransactionPerMicroframe; // 1 + additional transactions. Total: from 1 to 3)
88+
UCHAR Reserved4;
89+
ULONG MaxPacketSize;
90+
ULONG Reserved6;
91+
} USBPORT_ENDPOINT_PROPERTIES, *PUSBPORT_ENDPOINT_PROPERTIES;
92+
93+
C_ASSERT(sizeof(USBPORT_ENDPOINT_PROPERTIES) == 48 + 4 * sizeof(PVOID));
94+
95+
typedef struct _USBPORT_TRANSFER_PARAMETERS {
96+
ULONG TransferFlags;
97+
ULONG TransferBufferLength;
98+
ULONG TransferCounter;
99+
BOOL IsTransferSplited;
100+
ULONG Reserved2;
101+
USB_DEFAULT_PIPE_SETUP_PACKET SetupPacket;
102+
} USBPORT_TRANSFER_PARAMETERS, *PUSBPORT_TRANSFER_PARAMETERS;
103+
104+
C_ASSERT(sizeof(USBPORT_TRANSFER_PARAMETERS) == 28);
105+
106+
typedef struct _USBPORT_SCATTER_GATHER_ELEMENT {
107+
PHYSICAL_ADDRESS SgPhysicalAddress;
108+
ULONG Reserved1;
109+
ULONG SgTransferLength;
110+
ULONG SgOffset;
111+
ULONG Reserved2;
112+
} USBPORT_SCATTER_GATHER_ELEMENT, *PUSBPORT_SCATTER_GATHER_ELEMENT;
113+
114+
C_ASSERT(sizeof(USBPORT_SCATTER_GATHER_ELEMENT) == 24);
115+
116+
typedef struct _USBPORT_SCATTER_GATHER_LIST {
117+
ULONG Flags;
118+
ULONG_PTR CurrentVa;
119+
PVOID MappedSystemVa;
120+
ULONG SgElementCount;
121+
USBPORT_SCATTER_GATHER_ELEMENT SgElement[2];
122+
} USBPORT_SCATTER_GATHER_LIST, *PUSBPORT_SCATTER_GATHER_LIST;
123+
124+
C_ASSERT(sizeof(USBPORT_SCATTER_GATHER_LIST) == 48 + 4 * sizeof(PVOID));
125+
126+
typedef struct _USBPORT_ENDPOINT_REQUIREMENTS {
127+
ULONG HeaderBufferSize;
128+
ULONG MaxTransferSize;
129+
} USBPORT_ENDPOINT_REQUIREMENTS, *PUSBPORT_ENDPOINT_REQUIREMENTS;
130+
67131
typedef ULONG MPSTATUS; // Miniport status
68132
typedef ULONG RHSTATUS; // Roothub status
69133

@@ -88,20 +152,20 @@ typedef ULONG RHSTATUS; // Roothub status
88152
typedef MPSTATUS
89153
(NTAPI *PHCI_OPEN_ENDPOINT)(
90154
PVOID,
91-
PVOID,
155+
PUSBPORT_ENDPOINT_PROPERTIES,
92156
PVOID);
93157

94158
typedef MPSTATUS
95159
(NTAPI *PHCI_REOPEN_ENDPOINT)(
96160
PVOID,
97-
PVOID,
161+
PUSBPORT_ENDPOINT_PROPERTIES,
98162
PVOID);
99163

100164
typedef VOID
101165
(NTAPI *PHCI_QUERY_ENDPOINT_REQUIREMENTS)(
102166
PVOID,
103-
PVOID,
104-
PULONG);
167+
PUSBPORT_ENDPOINT_PROPERTIES,
168+
PUSBPORT_ENDPOINT_REQUIREMENTS);
105169

106170
typedef VOID
107171
(NTAPI *PHCI_CLOSE_ENDPOINT)(
@@ -137,15 +201,15 @@ typedef MPSTATUS
137201
(NTAPI *PHCI_SUBMIT_TRANSFER)(
138202
PVOID,
139203
PVOID,
204+
PUSBPORT_TRANSFER_PARAMETERS,
140205
PVOID,
141-
PVOID,
142-
PVOID);
206+
PUSBPORT_SCATTER_GATHER_LIST);
143207

144208
typedef MPSTATUS
145209
(NTAPI *PHCI_SUBMIT_ISO_TRANSFER)(
146210
PVOID,
147211
PVOID,
148-
PVOID,
212+
PUSBPORT_TRANSFER_PARAMETERS,
149213
PVOID,
150214
PVOID);
151215

@@ -443,7 +507,7 @@ typedef ULONG
443507
typedef VOID
444508
(NTAPI *PHCI_REBALANCE_ENDPOINT)(
445509
PVOID,
446-
PVOID,
510+
PUSBPORT_ENDPOINT_PROPERTIES,
447511
PVOID);
448512

449513
typedef VOID
@@ -583,65 +647,6 @@ C_ASSERT(sizeof(USBPORT_MINIPORT_INTERFACE) == 32 + 76 * sizeof(PVOID));
583647
#define USBPORT_TRANSFER_DIRECTION_OUT 1 // From host to device
584648
#define USBPORT_MAX_DEVICE_ADDRESS 127
585649

586-
typedef struct _USBPORT_ENDPOINT_PROPERTIES {
587-
USHORT DeviceAddress;
588-
USHORT EndpointAddress;
589-
USHORT TotalMaxPacketSize; // TransactionPerMicroframe * MaxPacketSize
590-
UCHAR Period;
591-
UCHAR Reserved1;
592-
USB_DEVICE_SPEED DeviceSpeed;
593-
ULONG UsbBandwidth;
594-
ULONG ScheduleOffset;
595-
ULONG TransferType;
596-
ULONG Direction;
597-
ULONG_PTR BufferVA;
598-
ULONG_PTR BufferPA;
599-
ULONG BufferLength;
600-
ULONG Reserved3;
601-
ULONG MaxTransferSize;
602-
USHORT HubAddr;
603-
USHORT PortNumber;
604-
UCHAR InterruptScheduleMask;
605-
UCHAR SplitCompletionMask;
606-
UCHAR TransactionPerMicroframe; // 1 + additional transactions. Total: from 1 to 3)
607-
UCHAR Reserved4;
608-
ULONG MaxPacketSize;
609-
ULONG Reserved6;
610-
} USBPORT_ENDPOINT_PROPERTIES, *PUSBPORT_ENDPOINT_PROPERTIES;
611-
612-
C_ASSERT(sizeof(USBPORT_ENDPOINT_PROPERTIES) == 48 + 4 * sizeof(PVOID));
613-
614-
typedef struct _USBPORT_SCATTER_GATHER_ELEMENT {
615-
PHYSICAL_ADDRESS SgPhysicalAddress;
616-
ULONG Reserved1;
617-
ULONG SgTransferLength;
618-
ULONG SgOffset;
619-
ULONG Reserved2;
620-
} USBPORT_SCATTER_GATHER_ELEMENT, *PUSBPORT_SCATTER_GATHER_ELEMENT;
621-
622-
C_ASSERT(sizeof(USBPORT_SCATTER_GATHER_ELEMENT) == 24);
623-
624-
typedef struct _USBPORT_SCATTER_GATHER_LIST {
625-
ULONG Flags;
626-
ULONG_PTR CurrentVa;
627-
PVOID MappedSystemVa;
628-
ULONG SgElementCount;
629-
USBPORT_SCATTER_GATHER_ELEMENT SgElement[2];
630-
} USBPORT_SCATTER_GATHER_LIST, *PUSBPORT_SCATTER_GATHER_LIST;
631-
632-
C_ASSERT(sizeof(USBPORT_SCATTER_GATHER_LIST) == 48 + 4 * sizeof(PVOID));
633-
634-
typedef struct _USBPORT_TRANSFER_PARAMETERS {
635-
ULONG TransferFlags;
636-
ULONG TransferBufferLength;
637-
ULONG TransferCounter;
638-
BOOL IsTransferSplited;
639-
ULONG Reserved2;
640-
USB_DEFAULT_PIPE_SETUP_PACKET SetupPacket;
641-
} USBPORT_TRANSFER_PARAMETERS, *PUSBPORT_TRANSFER_PARAMETERS;
642-
643-
C_ASSERT(sizeof(USBPORT_TRANSFER_PARAMETERS) == 28);
644-
645650
/* For USB1.1 or USB3 Hub Descriptors */
646651
typedef union _USBPORT_HUB_11_CHARACTERISTICS {
647652
struct {

0 commit comments

Comments
 (0)