[USBCCGP]
authorJohannes Anderwald <johannes.anderwald@reactos.org>
Thu, 2 Feb 2012 10:17:14 +0000 (10:17 +0000)
committerJohannes Anderwald <johannes.anderwald@reactos.org>
Thu, 2 Feb 2012 10:17:14 +0000 (10:17 +0000)
- Remove hacks used for broken usbd driver
- Implement IRP_MN_REMOVE for FDO & PDO

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

drivers/usb/usbccgp/descriptor.c
drivers/usb/usbccgp/fdo.c
drivers/usb/usbccgp/pdo.c
drivers/usb/usbccgp/usbccgp.h

index f4c30e9..e8e74f8 100644 (file)
@@ -259,8 +259,6 @@ AllocateInterfaceDescriptorsArray(
     return STATUS_SUCCESS;
 }
 
-
-
 NTSTATUS
 NTAPI
 USBCCGP_ScanConfigurationDescriptor(
@@ -281,7 +279,7 @@ USBCCGP_ScanConfigurationDescriptor(
     //
     // count all interface descriptors
     //
-    DescriptorCount = CountInterfaceDescriptors(ConfigurationDescriptor);
+    DescriptorCount = ConfigurationDescriptor->bNumInterfaces;
 
     //
     // allocate array holding the interface descriptors
@@ -302,6 +300,7 @@ USBCCGP_ScanConfigurationDescriptor(
         // parse configuration descriptor
         //
         InterfaceDescriptor = USBD_ParseConfigurationDescriptorEx(ConfigurationDescriptor, ConfigurationDescriptor, InterfaceIndex, -1, -1, -1, -1);
+        ASSERT(InterfaceDescriptor);
         if (InterfaceDescriptor)
         {
             //
index fe89da1..d4bfacf 100644 (file)
@@ -279,6 +279,7 @@ FDO_CreateChildPdo(
         PDODeviceExtension->FunctionDescriptor = &FDODeviceExtension->FunctionDescriptor[Index];
         PDODeviceExtension->NextDeviceObject = FDODeviceExtension->NextDeviceObject; //DeviceObject; HACK
         PDODeviceExtension->FunctionIndex = Index;
+        PDODeviceExtension->FDODeviceExtension = FDODeviceExtension;
         PDODeviceExtension->InterfaceList = FDODeviceExtension->InterfaceList;
         PDODeviceExtension->InterfaceListCount = FDODeviceExtension->InterfaceListCount;
         PDODeviceExtension->ConfigurationHandle = FDODeviceExtension->ConfigurationHandle;
@@ -423,9 +424,31 @@ FDO_HandlePnp(
 
     // get stack location
     IoStack = IoGetCurrentIrpStackLocation(Irp);
-       DPRINT1("[USBCCGP] PnP Minor %x\n", IoStack->MinorFunction);
+    DPRINT1("[USBCCGP] PnP Minor %x\n", IoStack->MinorFunction);
     switch(IoStack->MinorFunction)
     {
+        case IRP_MN_REMOVE_DEVICE:
+        {
+            /* Send the IRP down the stack */
+            Status = USBCCGP_SyncForwardIrp(FDODeviceExtension->NextDeviceObject, Irp);
+            if (NT_SUCCESS(Status))
+            {
+                //
+                // Detach from the device stack
+                //
+                IoDetachDevice(FDODeviceExtension->NextDeviceObject);
+
+                //
+                // Delete the device object
+                //
+                IoDeleteDevice(DeviceObject);
+            }
+
+            //
+            // request completed
+            //
+            break;
+        }
         case IRP_MN_START_DEVICE:
         {
             //
index 22d0697..9d7180d 100644 (file)
@@ -307,6 +307,7 @@ PDO_HandlePnp(
     PIO_STACK_LOCATION IoStack;
     PPDO_DEVICE_EXTENSION PDODeviceExtension;
     NTSTATUS Status;
+    ULONG Index;
 
     //
     // get current stack location
@@ -351,15 +352,31 @@ PDO_HandlePnp(
        }
        case IRP_MN_REMOVE_DEVICE:
        {
-           DPRINT1("IRP_MN_REMOVE_DEVICE\n");
+           //
+           // remove us from the fdo's pdo list
+           //
+           for(Index = 0; Index < PDODeviceExtension->FDODeviceExtension->FunctionDescriptorCount; Index++)
+           {
+               if (PDODeviceExtension->FDODeviceExtension->ChildPDO[Index] == DeviceObject)
+               {
+                   //
+                   // remove us
+                   //
+                   PDODeviceExtension->FDODeviceExtension->ChildPDO[Index] = NULL;
+                   break;
+               }
+           }
 
-           /* Complete the IRP */
+           //
+           // Complete the IRP
+           //
            Irp->IoStatus.Status = STATUS_SUCCESS;
            IoCompleteRequest(Irp, IO_NO_INCREMENT);
 
-           /* Delete the device object */
+           //
+           // Delete the device object
+           //
            IoDeleteDevice(DeviceObject);
-
            return STATUS_SUCCESS;
        }
        case IRP_MN_QUERY_CAPABILITIES:
index 04134fe..55e0806 100644 (file)
@@ -55,6 +55,7 @@ typedef struct
     USBD_CONFIGURATION_HANDLE ConfigurationHandle;           // configuration handle
     PUSBD_INTERFACE_LIST_ENTRY InterfaceList;                // interface list
     ULONG InterfaceListCount;                                // interface list count
+    PFDO_DEVICE_EXTENSION FDODeviceExtension;                        // pointer to fdo's pdo list
 }PDO_DEVICE_EXTENSION, *PPDO_DEVICE_EXTENSION;
 
 /* descriptor.c */