[USBCCGP] Allow unconfiguring the device in USBCCGP_PDOSelectConfiguration.
[reactos.git] / drivers / usb / usbccgp / pdo.c
index 617b299..bcd0acb 100644 (file)
 
 #include "usbccgp.h"
 
+#include <ntddk.h>
+
+#define NDEBUG
+#include <debug.h>
+
 NTSTATUS
 USBCCGP_PdoHandleQueryDeviceText(
     IN PDEVICE_OBJECT DeviceObject,
@@ -52,7 +57,7 @@ USBCCGP_PdoHandleQueryDeviceText(
     //
     // FIXME use GenericCompositeUSBDeviceString
     //
-    UNIMPLEMENTED
+    UNIMPLEMENTED;
     Buffer = AllocateItem(PagedPool, (wcslen(GenericString) + 1) * sizeof(WCHAR));
     if (!Buffer)
     {
@@ -713,6 +718,14 @@ USBCCGP_PDOSelectConfiguration(
         return STATUS_SUCCESS;
     }
 
+    //
+    // if there is no configuration descriptor, unconfigure the device
+    //
+    if (Urb->UrbSelectConfiguration.ConfigurationDescriptor == NULL)
+    {
+        return STATUS_SUCCESS;
+    }
+
     // sanity checks
     //C_ASSERT(sizeof(struct _URB_HEADER) == 16);
     //C_ASSERT(FIELD_OFFSET(struct _URB_SELECT_CONFIGURATION, Interface.Length) == 24);
@@ -752,7 +765,6 @@ USBCCGP_PDOSelectConfiguration(
             // invalid parameter
             //
             DPRINT1("InterfaceInformation InterfaceNumber %x Alternative %x NumberOfPipes %x not found\n", InterfaceInformation->InterfaceNumber, InterfaceInformation->AlternateSetting, InterfaceInformation->NumberOfPipes);
-            ASSERT(FALSE);
             return STATUS_INVALID_PARAMETER;
         }
 
@@ -1076,6 +1088,11 @@ PDO_Dispatch(
             return PDO_HandlePnp(DeviceObject, Irp);
         case IRP_MJ_INTERNAL_DEVICE_CONTROL:
             return PDO_HandleInternalDeviceControl(DeviceObject, Irp);
+        case IRP_MJ_POWER:
+            PoStartNextPowerIrp(Irp);
+            Irp->IoStatus.Status = STATUS_SUCCESS;
+            IoCompleteRequest(Irp, IO_NO_INCREMENT);
+            return STATUS_SUCCESS;
         default:
             DPRINT1("PDO_Dispatch Function %x not implemented\n", IoStack->MajorFunction);
             Status = Irp->IoStatus.Status;