@@ -2030,7 +2030,9 @@ USBHUB_FdoHandlePnp(
2030
2030
{
2031
2031
PIO_STACK_LOCATION Stack ;
2032
2032
NTSTATUS Status = STATUS_SUCCESS ;
2033
+ PDEVICE_OBJECT ChildDeviceObject ;
2033
2034
PHUB_DEVICE_EXTENSION HubDeviceExtension ;
2035
+ PHUB_CHILDDEVICE_EXTENSION ChildDeviceExtension ;
2034
2036
2035
2037
HubDeviceExtension = (PHUB_DEVICE_EXTENSION ) DeviceObject -> DeviceExtension ;
2036
2038
@@ -2098,10 +2100,49 @@ USBHUB_FdoHandlePnp(
2098
2100
}
2099
2101
break ;
2100
2102
}
2101
- case IRP_MN_QUERY_REMOVE_DEVICE :
2102
2103
case IRP_MN_QUERY_STOP_DEVICE :
2103
2104
{
2104
- DPRINT ("IRP_MN_QUERY_STOP_DEVICE\n" );
2105
+ //
2106
+ // We should fail this request, because we're not handling
2107
+ // IRP_MN_STOP_DEVICE for now.We'll receive this IRP ONLY when
2108
+ // PnP manager rebalances resources.
2109
+ //
2110
+ Irp -> IoStatus .Status = STATUS_NOT_SUPPORTED ;
2111
+ IoCompleteRequest (Irp , IO_NO_INCREMENT );
2112
+ return STATUS_NOT_SUPPORTED ;
2113
+ }
2114
+ case IRP_MN_QUERY_REMOVE_DEVICE :
2115
+ {
2116
+ // No action is required from FDO because it have nothing to free.
2117
+ DPRINT ("IRP_MN_QUERY_REMOVE_DEVICE\n" );
2118
+
2119
+ Irp -> IoStatus .Status = STATUS_SUCCESS ;
2120
+ break ;
2121
+ }
2122
+ case IRP_MN_SURPRISE_REMOVAL :
2123
+ {
2124
+ //
2125
+ // We'll receive this IRP on HUB unexpected removal, or on USB
2126
+ // controller removal from PCI port. Here we should "let know" all
2127
+ // our children that their parent is removed and on next removal
2128
+ // they also can be removed.
2129
+ //
2130
+
2131
+ KeAcquireGuardedMutex (& HubDeviceExtension -> HubMutexLock );
2132
+
2133
+ for (int i = 0 ; i < USB_MAXCHILDREN ; i ++ )
2134
+ {
2135
+ ChildDeviceObject = HubDeviceExtension -> ChildDeviceObject [i ];
2136
+ if (ChildDeviceObject )
2137
+ {
2138
+ ChildDeviceExtension = (PHUB_CHILDDEVICE_EXTENSION )ChildDeviceObject -> DeviceObjectExtension ;
2139
+ ChildDeviceExtension -> ParentDeviceObject = NULL ;
2140
+ }
2141
+ }
2142
+
2143
+ KeReleaseGuardedMutex (& HubDeviceExtension -> HubMutexLock );
2144
+
2145
+ // This IRP can't be failed
2105
2146
Irp -> IoStatus .Status = STATUS_SUCCESS ;
2106
2147
break ;
2107
2148
}
0 commit comments