[USBOHCI]
authorJohannes Anderwald <johannes.anderwald@reactos.org>
Wed, 1 Feb 2012 02:36:53 +0000 (02:36 +0000)
committerJohannes Anderwald <johannes.anderwald@reactos.org>
Wed, 1 Feb 2012 02:36:53 +0000 (02:36 +0000)
- Fix bugs in HandleClassEndpoint, HandleClassInterface which always set direction device to host instead of relying to the transfer flags provided
- Allow setup packets w/o a data stage

svn path=/branches/usb-bringup-trunk/; revision=55360

drivers/usb/usbohci/hub_controller.cpp
drivers/usb/usbohci/usb_device.cpp

index 02e96cb..c89cf5a 100644 (file)
@@ -1660,12 +1660,21 @@ CHubController::HandleClassEndpoint(
     //
     // initialize setup packet
     //
-    CtrlSetup.bmRequestType.B = 0xa2; //FIXME: Const.
+    CtrlSetup.bmRequestType.B = 0x22; //FIXME: Const.
     CtrlSetup.bRequest = Urb->UrbControlVendorClassRequest.Request;
     CtrlSetup.wValue.W = Urb->UrbControlVendorClassRequest.Value;
     CtrlSetup.wIndex.W = Urb->UrbControlVendorClassRequest.Index;
     CtrlSetup.wLength = Urb->UrbControlVendorClassRequest.TransferBufferLength;
 
+    if (Urb->UrbControlVendorClassRequest.TransferFlags & USBD_TRANSFER_DIRECTION_IN)
+    {
+        //
+        // data direction is device to host
+        //
+        CtrlSetup.bmRequestType.B |= 0x80;
+    }
+
+
     //
     // issue request
     //
@@ -1729,24 +1738,23 @@ CHubController::HandleClassInterface(
     DPRINT1("Value %x\n", Urb->UrbControlVendorClassRequest.Value);
     DPRINT1("Index %x\n", Urb->UrbControlVendorClassRequest.Index);
 
-    if (Urb->UrbControlVendorClassRequest.TransferBufferLength == 0)
-    {
-        //
-        // FIXME: support requests w/o data stage
-        //;
-        ASSERT(FALSE);
-        return STATUS_SUCCESS;
-    }
-
     //
     // initialize setup packet
     //
-    CtrlSetup.bmRequestType.B = 0xa1;
+    CtrlSetup.bmRequestType.B = 0x21;
     CtrlSetup.bRequest = Urb->UrbControlVendorClassRequest.Request;
     CtrlSetup.wValue.W = Urb->UrbControlVendorClassRequest.Value;
     CtrlSetup.wIndex.W = Urb->UrbControlVendorClassRequest.Index;
     CtrlSetup.wLength = Urb->UrbControlVendorClassRequest.TransferBufferLength;
 
+    if (Urb->UrbControlVendorClassRequest.TransferFlags & USBD_TRANSFER_DIRECTION_IN)
+    {
+        //
+        // data direction is device to host
+        //
+        CtrlSetup.bmRequestType.B |= 0x80;
+    }
+
     //
     // issue request
     //
index 6793669..0c1cf9c 100644 (file)
@@ -858,27 +858,35 @@ CUSBDevice::SubmitSetupPacket(
     OUT PVOID Buffer)
 {
     NTSTATUS Status;
-    PMDL Mdl;
+    PMDL Mdl = NULL;
 
-    //
-    // allocate mdl
-    //
-    Mdl = IoAllocateMdl(Buffer, BufferLength, FALSE, FALSE, 0);
+    if (BufferLength)
+    {
+        //
+        // allocate mdl
+        //
+        Mdl = IoAllocateMdl(Buffer, BufferLength, FALSE, FALSE, 0);
+        if (!Mdl)
+            return STATUS_INSUFFICIENT_RESOURCES;
 
-    //
-    // HACK HACK HACK: assume the buffer is build from non paged pool
-    //
-    MmBuildMdlForNonPagedPool(Mdl);
+        //
+        // HACK HACK HACK: assume the buffer is build from non paged pool
+        //
+        MmBuildMdlForNonPagedPool(Mdl);
+    }
 
     //
     // commit setup packet
     //
     Status = CommitSetupPacket(SetupPacket, 0, BufferLength, Mdl);
 
-    //
-    // free mdl
-    //
-    IoFreeMdl(Mdl);
+    if (Mdl != NULL)
+    {
+        //
+        // free mdl
+        //
+        IoFreeMdl(Mdl);
+    }
 
     //
     // done