Author: vmikayelyan
Date: Fri Aug 19 16:52:21 2016
New Revision: 72391
URL:
http://svn.reactos.org/svn/reactos?rev=72391&view=rev
Log:
usb: HUB: Refactor power dispatcher, add remove synch
Refactored power dispatcher, added remove sychronization to avoid early
remove or call on removed device.
Modified:
branches/GSoC_2016/USB/drivers/usb/usbhub/usbhub.c
Modified: branches/GSoC_2016/USB/drivers/usb/usbhub/usbhub.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/USB/drivers/usb/usbhu…
==============================================================================
--- branches/GSoC_2016/USB/drivers/usb/usbhub/usbhub.c [iso-8859-1] (original)
+++ branches/GSoC_2016/USB/drivers/usb/usbhub/usbhub.c [iso-8859-1] Fri Aug 19 16:52:21
2016
@@ -197,45 +197,58 @@
{
PIO_STACK_LOCATION IoStack;
PHUB_DEVICE_EXTENSION DeviceExtension;
-
+ NTSTATUS Status;
IoStack = IoGetCurrentIrpStackLocation(Irp);
DeviceExtension = DeviceObject->DeviceExtension;
+
+ Status = IoAcquireRemoveLock(&DeviceExtension->Common.RemoveLock, Irp);
+ if (!NT_SUCCESS(Status))
+ {
+ Irp->IoStatus.Status = Status;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return Status;
+ }
+
DPRINT1("Power Function %x\n", IoStack->MinorFunction);
if (DeviceExtension->Common.IsFDO)
{
PoStartNextPowerIrp(Irp);
IoSkipCurrentIrpStackLocation(Irp);
- return PoCallDriver(DeviceExtension->LowerDeviceObject, Irp);
- }
-
- if (IoStack->MinorFunction == IRP_MN_SET_POWER)
- {
- PoStartNextPowerIrp(Irp);
- Irp->IoStatus.Status = STATUS_SUCCESS;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return STATUS_SUCCESS;
-
- }
- else if (IoStack->MinorFunction == IRP_MN_QUERY_POWER)
- {
- PoStartNextPowerIrp(Irp);
- Irp->IoStatus.Status = STATUS_SUCCESS;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return STATUS_SUCCESS;
-
- }
- else if (IoStack->MinorFunction == IRP_MN_WAIT_WAKE)
- {
- PoStartNextPowerIrp(Irp);
- Irp->IoStatus.Status = STATUS_SUCCESS;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return STATUS_SUCCESS;
+ Status = PoCallDriver(DeviceExtension->LowerDeviceObject, Irp);
+ IoReleaseRemoveLock(&DeviceExtension->Common.RemoveLock, Irp);
+ return Status;
+ }
+
+ switch (IoStack->MinorFunction)
+ {
+ case IRP_MN_SET_POWER:
+ {
+ DPRINT("IRP_MN_SET_POWER\n");
+ break;
+ }
+ case IRP_MN_QUERY_POWER:
+ {
+ DPRINT("IRP_MN_QUERY_POWER\n");
+ break;
+ }
+ case IRP_MN_WAIT_WAKE:
+ {
+ DPRINT("IRP_MN_WAIT_WAKE\n");
+ break;
+ }
+ default:
+ {
+ DPRINT1("PDO IRP_MJ_POWER / unknown minor function 0x%lx\n",
IoStack->MinorFunction);
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return Irp->IoStatus.Status;
+ }
}
PoStartNextPowerIrp(Irp);
Irp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ IoReleaseRemoveLock(&DeviceExtension->Common.RemoveLock, Irp);
return STATUS_SUCCESS;
}