[LIBUSB][USBCCGP]
[reactos.git] / reactos / lib / drivers / libusb / usb_device.cpp
index 2dc0fa6..2050dd0 100644 (file)
@@ -323,7 +323,7 @@ CUSBDevice::SetDeviceAddress(
     CtrlSetup->wValue.W = DeviceAddress;
 
     // set device address
-    Status = CommitSetupPacket(CtrlSetup, 0, 0, 0);
+    Status = CommitSetupPacket(CtrlSetup, NULL, 0, NULL);
 
     // free setup packet
     ExFreePoolWithTag(CtrlSetup, TAG_USBLIB);
@@ -380,7 +380,7 @@ CUSBDevice::SetDeviceAddress(
     RtlZeroMemory(m_ConfigurationDescriptors, sizeof(USB_CONFIGURATION) * m_DeviceDescriptor.bNumConfigurations);
 
     // retrieve the configuration descriptors
-    for(Index = 0; Index < m_DeviceDescriptor.bNumConfigurations; Index++)
+    for (Index = 0; Index < m_DeviceDescriptor.bNumConfigurations; Index++)
     {
         // retrieve configuration descriptors from device
         Status = CreateConfigurationDescriptor(Index);
@@ -640,7 +640,7 @@ CUSBDevice::CreateDeviceDescriptor()
     //
     // commit setup packet
     //
-    Status = CommitSetupPacket(&CtrlSetup, 0, sizeof(USB_DEVICE_DESCRIPTOR), Mdl);
+    Status = CommitSetupPacket(&CtrlSetup, NULL, sizeof(USB_DEVICE_DESCRIPTOR), Mdl);
 
     //
     // now free the mdl
@@ -713,7 +713,7 @@ CUSBDevice::GetConfigurationDescriptor(
     //
     // commit packet
     //
-    Status = CommitSetupPacket(&CtrlSetup, 0, BufferSize, Mdl);
+    Status = CommitSetupPacket(&CtrlSetup, NULL, BufferSize, Mdl);
 
     //
     // free mdl
@@ -809,6 +809,8 @@ CUSBDevice::GetConfigurationDescriptors(
     IN ULONG BufferLength,
     OUT PULONG OutBufferLength)
 {
+    ULONG Length;
+
     // sanity check
     ASSERT(BufferLength >= sizeof(USB_CONFIGURATION_DESCRIPTOR));
     ASSERT(ConfigDescriptorBuffer);
@@ -821,8 +823,9 @@ CUSBDevice::GetConfigurationDescriptors(
     PC_ASSERT(m_DeviceDescriptor.bNumConfigurations == 1);
 
     // copy configuration descriptor
-    RtlCopyMemory(ConfigDescriptorBuffer, m_ConfigurationDescriptors[0].ConfigurationDescriptor, min(m_ConfigurationDescriptors[0].ConfigurationDescriptor->wTotalLength, BufferLength));
-    *OutBufferLength = m_ConfigurationDescriptors[0].ConfigurationDescriptor->wTotalLength;
+    Length = min(m_ConfigurationDescriptors[0].ConfigurationDescriptor->wTotalLength, BufferLength);
+    RtlCopyMemory(ConfigDescriptorBuffer, m_ConfigurationDescriptors[0].ConfigurationDescriptor, Length);
+    *OutBufferLength = Length;
 }
 
 //----------------------------------------------------------------------------------------
@@ -904,7 +907,7 @@ CUSBDevice::SubmitSetupPacket(
     //
     // commit setup packet
     //
-    Status = CommitSetupPacket(SetupPacket, 0, BufferLength, Mdl);
+    Status = CommitSetupPacket(SetupPacket, NULL, BufferLength, Mdl);
 
     if (Mdl != NULL)
     {
@@ -1026,7 +1029,7 @@ CUSBDevice::SelectConfiguration(
     if (ConfigurationDescriptor)
     {
         // find configuration index
-        for(Index = 0; Index < m_DeviceDescriptor.bNumConfigurations; Index++)
+        for (Index = 0; Index < m_DeviceDescriptor.bNumConfigurations; Index++)
         {
             if (m_ConfigurationDescriptors[Index].ConfigurationDescriptor->bConfigurationValue  == ConfigurationDescriptor->bConfigurationValue)
             {
@@ -1038,7 +1041,7 @@ CUSBDevice::SelectConfiguration(
 
         if (!Found)
         {
-            DPRINT1("[USBLIB] invalid configuration value %lu\n", ConfigurationDescriptor->bConfigurationValue);
+            DPRINT1("[USBLIB] invalid configuration value %u\n", ConfigurationDescriptor->bConfigurationValue);
             return STATUS_INVALID_PARAMETER;
         }
 
@@ -1055,18 +1058,18 @@ CUSBDevice::SelectConfiguration(
     CtrlSetup.wValue.W = bConfigurationValue;
 
     // select configuration
-    Status = CommitSetupPacket(&CtrlSetup, 0, 0, 0);
+    Status = CommitSetupPacket(&CtrlSetup, NULL, 0, NULL);
 
     if (!ConfigurationDescriptor)
     {
         // unconfigure request
-        DPRINT1("CUSBDevice::SelectConfiguration Unconfigure Request Status %x\n", Status);
+        DPRINT1("CUSBDevice::SelectConfiguration Unconfigure Request Status %lx\n", Status);
         m_ConfigurationIndex = 0;
         return Status;
     }
 
     // informal debug print
-    DPRINT1("CUSBDevice::SelectConfiguration New Configuration %x Old Configuration %x Result %x\n", ConfigurationIndex, m_ConfigurationIndex, Status);
+    DPRINT1("CUSBDevice::SelectConfiguration New Configuration %x Old Configuration %x Result %lx\n", ConfigurationIndex, m_ConfigurationIndex, Status);
     if (!NT_SUCCESS(Status))
     {
         //
@@ -1076,7 +1079,7 @@ CUSBDevice::SelectConfiguration(
     }
 
     // destroy old interface info
-    while(!IsListEmpty(&m_ConfigurationDescriptors[m_ConfigurationIndex].InterfaceList))
+    while (!IsListEmpty(&m_ConfigurationDescriptors[m_ConfigurationIndex].InterfaceList))
     {
         // remove entry
         Entry = RemoveHeadList(&m_ConfigurationDescriptors[m_ConfigurationIndex].InterfaceList);
@@ -1174,12 +1177,12 @@ CUSBDevice::SelectInterface(
     CtrlSetup.bmRequestType.B = 0x01;
 
     // issue request
-    Status = CommitSetupPacket(&CtrlSetup, 0, 0, 0);
+    Status = CommitSetupPacket(&CtrlSetup, NULL, 0, NULL);
 
     // informal debug print
-    DPRINT1("CUSBDevice::SelectInterface AlternateSetting %x InterfaceNumber %x Status %x\n", InterfaceInfo->AlternateSetting, InterfaceInfo->InterfaceNumber, Status);
+    DPRINT1("CUSBDevice::SelectInterface AlternateSetting %x InterfaceNumber %x Status %lx\n", InterfaceInfo->AlternateSetting, InterfaceInfo->InterfaceNumber, Status);
 #if 0
-       if (!NT_SUCCESS(Status))
+    if (!NT_SUCCESS(Status))
     {
         // failed to select interface
         return Status;
@@ -1188,11 +1191,10 @@ CUSBDevice::SelectInterface(
 
     Status = STATUS_SUCCESS;
 
-
     // find interface
     Found = FALSE;
     Entry = m_ConfigurationDescriptors[ConfigurationIndex].InterfaceList.Flink;
-    while(Entry != &m_ConfigurationDescriptors[ConfigurationIndex].InterfaceList)
+    while (Entry != &m_ConfigurationDescriptors[ConfigurationIndex].InterfaceList)
     {
         // grab interface descriptor
         UsbInterface = (PUSB_INTERFACE)CONTAINING_RECORD(Entry, USB_INTERFACE, ListEntry);
@@ -1238,7 +1240,7 @@ CUSBDevice::SelectInterface(
     InterfaceInfo->NumberOfPipes = UsbInterface->InterfaceDescriptor->bNumEndpoints;
 
     // copy pipe handles
-    for(PipeIndex = 0; PipeIndex < UsbInterface->InterfaceDescriptor->bNumEndpoints; PipeIndex++)
+    for (PipeIndex = 0; PipeIndex < UsbInterface->InterfaceDescriptor->bNumEndpoints; PipeIndex++)
     {
         // copy pipe handle
         DPRINT1("PipeIndex %lu\n", PipeIndex);
@@ -1247,7 +1249,7 @@ CUSBDevice::SelectInterface(
         DPRINT1("MaximumPacketSize %d\n", InterfaceInfo->Pipes[PipeIndex].MaximumPacketSize);
         DPRINT1("MaximumTransferSize %d\n", InterfaceInfo->Pipes[PipeIndex].MaximumTransferSize);
         DPRINT1("PipeFlags %d\n", InterfaceInfo->Pipes[PipeIndex].PipeFlags);
-        DPRINT1("PipeType %dd\n", InterfaceInfo->Pipes[PipeIndex].PipeType);
+        DPRINT1("PipeType %d\n", InterfaceInfo->Pipes[PipeIndex].PipeType);
         DPRINT1("UsbEndPoint %x\n", InterfaceInfo->Pipes[PipeIndex].EndpointAddress);
 
         // sanity checks
@@ -1261,7 +1263,6 @@ CUSBDevice::SelectInterface(
         UsbInterface->EndPoints[PipeIndex].DataToggle = FALSE;
     }
 
-
     //
     // done
     //