[USB-BRINGUP-TRUNK]
authorCameron Gutman <aicommander@gmail.com>
Mon, 23 Jan 2012 00:50:25 +0000 (00:50 +0000)
committerCameron Gutman <aicommander@gmail.com>
Mon, 23 Jan 2012 00:50:25 +0000 (00:50 +0000)
- Don't send removal IRPs to device nodes already pending removal
- USB device removal and reinsertion works now

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

ntoskrnl/io/pnpmgr/pnpmgr.c

index 8a7df58..9d20b97 100644 (file)
@@ -1824,14 +1824,11 @@ IopHandleDeviceRemoval(
             }
         }
 
-        if (!Found)
+        if (!Found && !(Child->Flags & DNF_WILL_BE_REMOVED))
         {
             /* Send removal IRPs to all of its children */
             IopPrepareDeviceForRemoval(Child->PhysicalDeviceObject, TRUE);
 
-            /* Set the flag */
-            Child->Flags |= DNF_WILL_BE_REMOVED;
-
             /* Send the surprise removal IRP */
             IopSendSurpriseRemoval(Child->PhysicalDeviceObject);
 
@@ -4166,6 +4163,7 @@ IopPrepareDeviceForRemoval(IN PDEVICE_OBJECT DeviceObject, BOOLEAN Force)
         return Status;
     }
 
+    DeviceNode->Flags |= DNF_WILL_BE_REMOVED;
     if (DeviceRelations)
         IopSendRemoveDeviceRelations(DeviceRelations);
     IopSendRemoveChildDevices(DeviceNode);
@@ -4186,7 +4184,6 @@ IopRemoveDevice(PDEVICE_NODE DeviceNode)
         IopSendRemoveDevice(DeviceNode->PhysicalDeviceObject);
         IopQueueTargetDeviceEvent(&GUID_DEVICE_SAFE_REMOVAL,
                                   &DeviceNode->InstancePath);
-        DeviceNode->Flags |= DNF_WILL_BE_REMOVED;
         return STATUS_SUCCESS;
     }