Synchronize with trunk's revision r57599.
[reactos.git] / drivers / usb / usbhub / pdo.c
index 939a9f3..6c561b9 100644 (file)
@@ -558,6 +558,7 @@ USBHUB_PdoHandlePnp(
     ULONG Index;
     ULONG bFound;
     PDEVICE_RELATIONS DeviceRelation;
+    PDEVICE_OBJECT ParentDevice;
 
     UsbChildExtension = (PHUB_CHILDDEVICE_EXTENSION)DeviceObject->DeviceExtension;
     Stack = IoGetCurrentIrpStackLocation(Irp);
@@ -645,6 +646,7 @@ USBHUB_PdoHandlePnp(
         {
             PHUB_DEVICE_EXTENSION HubDeviceExtension = (PHUB_DEVICE_EXTENSION)UsbChildExtension->ParentDeviceObject->DeviceExtension;
             PUSB_BUS_INTERFACE_HUB_V5 HubInterface = &HubDeviceExtension->HubInterface;
+            ParentDevice = UsbChildExtension->ParentDeviceObject;
 
             DPRINT("IRP_MJ_PNP / IRP_MN_REMOVE_DEVICE\n");
 
@@ -671,10 +673,13 @@ USBHUB_PdoHandlePnp(
             Irp->IoStatus.Status = STATUS_SUCCESS;
             IoCompleteRequest(Irp, IO_NO_INCREMENT);
 
+            /* delete device */
+            IoDeleteDevice(DeviceObject);
+
             if (bFound)
             {
-                /* Delete the device object */
-                IoDeleteDevice(DeviceObject);
+                /* invalidate device relations */
+                IoInvalidateDeviceRelations(ParentDevice, BusRelations);
             }
 
             return STATUS_SUCCESS;
@@ -731,6 +736,12 @@ USBHUB_PdoHandlePnp(
             IoSkipCurrentIrpStackLocation(Irp);
             return IoCallDriver(UsbChildExtension->ParentDeviceObject, Irp);
         }
+        case IRP_MN_SURPRISE_REMOVAL:
+        {
+            DPRINT("[USBHUB] HandlePnp IRP_MN_SURPRISE_REMOVAL\n");
+            Status = STATUS_SUCCESS;
+            break;
+        }
         default:
         {
             DPRINT1("PDO IRP_MJ_PNP / unknown minor function 0x%lx\n", MinorFunction);