Author: cgutman
Date: Fri Feb 3 22:59:53 2012
New Revision: 55399
URL:
http://svn.reactos.org/svn/reactos?rev=55399&view=rev
Log:
[PCI][HIDCLASS][HIDUSB][KBDHID][MOUHID][USBCCGP][USBOHCI][USBEHCI][USBHUB][USBSTOR]
- Handle query remove IRPs
- Fix some other removal bugs
Modified:
branches/usb-bringup-trunk/drivers/bus/pci/fdo.c
branches/usb-bringup-trunk/drivers/bus/pci/pdo.c
branches/usb-bringup-trunk/drivers/hid/hidclass/fdo.c
branches/usb-bringup-trunk/drivers/hid/hidusb/hidusb.c
branches/usb-bringup-trunk/drivers/hid/kbdhid/kbdhid.c
branches/usb-bringup-trunk/drivers/hid/mouhid/mouhid.c
branches/usb-bringup-trunk/drivers/usb/usbccgp/fdo.c
branches/usb-bringup-trunk/drivers/usb/usbccgp/pdo.c
branches/usb-bringup-trunk/drivers/usb/usbehci_new/hub_controller.cpp
branches/usb-bringup-trunk/drivers/usb/usbhub_new/fdo.c
branches/usb-bringup-trunk/drivers/usb/usbhub_new/pdo.c
branches/usb-bringup-trunk/drivers/usb/usbohci/hub_controller.cpp
branches/usb-bringup-trunk/drivers/usb/usbstor/fdo.c
branches/usb-bringup-trunk/drivers/usb/usbstor/pdo.c
Modified: branches/usb-bringup-trunk/drivers/bus/pci/fdo.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/bus/p…
==============================================================================
--- branches/usb-bringup-trunk/drivers/bus/pci/fdo.c [iso-8859-1] (original)
+++ branches/usb-bringup-trunk/drivers/bus/pci/fdo.c [iso-8859-1] Fri Feb 3 22:59:53
2012
@@ -96,7 +96,6 @@
{
PFDO_DEVICE_EXTENSION DeviceExtension;
PCI_COMMON_CONFIG PciConfig;
- PLIST_ENTRY CurrentEntry;
PPCI_DEVICE Device;
PCI_SLOT_NUMBER SlotNumber;
ULONG DeviceNumber;
@@ -107,15 +106,6 @@
DPRINT("Called\n");
DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
-
- /* Mark all devices to be removed. If we don't discover them again during
- enumeration, assume that they have been surprise removed */
- CurrentEntry = DeviceExtension->DeviceListHead.Flink;
- while (CurrentEntry != &DeviceExtension->DeviceListHead) {
- Device = CONTAINING_RECORD(CurrentEntry, PCI_DEVICE, ListEntry);
- Device->RemovePending = TRUE;
- CurrentEntry = CurrentEntry->Flink;
- }
DeviceExtension->DeviceListCount = 0;
@@ -189,9 +179,6 @@
&Device->ListEntry,
&DeviceExtension->DeviceListLock);
}
-
- /* Don't remove this device */
- Device->RemovePending = FALSE;
DeviceExtension->DeviceListCount++;
Modified: branches/usb-bringup-trunk/drivers/bus/pci/pdo.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/bus/p…
==============================================================================
--- branches/usb-bringup-trunk/drivers/bus/pci/pdo.c [iso-8859-1] (original)
+++ branches/usb-bringup-trunk/drivers/bus/pci/pdo.c [iso-8859-1] Fri Feb 3 22:59:53
2012
@@ -1443,10 +1443,33 @@
case IRP_MN_STOP_DEVICE:
case IRP_MN_QUERY_REMOVE_DEVICE:
case IRP_MN_CANCEL_REMOVE_DEVICE:
- case IRP_MN_REMOVE_DEVICE:
case IRP_MN_SURPRISE_REMOVAL:
Status = STATUS_SUCCESS;
break;
+
+ case IRP_MN_REMOVE_DEVICE:
+ {
+ PPDO_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
+ PFDO_DEVICE_EXTENSION FdoDeviceExtension =
DeviceExtension->Fdo->DeviceExtension;
+ KIRQL OldIrql;
+
+ /* Remove it from the device list */
+ KeAcquireSpinLock(&FdoDeviceExtension->DeviceListLock, &OldIrql);
+ RemoveEntryList(&DeviceExtension->PciDevice->ListEntry);
+ FdoDeviceExtension->DeviceListCount--;
+ KeReleaseSpinLock(&FdoDeviceExtension->DeviceListLock, OldIrql);
+
+ /* Free the device */
+ ExFreePool(DeviceExtension->PciDevice);
+
+ /* Complete the IRP */
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+
+ /* Delete the DO */
+ IoDeleteDevice(DeviceObject);
+ return STATUS_SUCCESS;
+ }
case IRP_MN_QUERY_INTERFACE:
DPRINT("IRP_MN_QUERY_INTERFACE received\n");
Modified: branches/usb-bringup-trunk/drivers/hid/hidclass/fdo.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/hid/h…
==============================================================================
--- branches/usb-bringup-trunk/drivers/hid/hidclass/fdo.c [iso-8859-1] (original)
+++ branches/usb-bringup-trunk/drivers/hid/hidclass/fdo.c [iso-8859-1] Fri Feb 3 22:59:53
2012
@@ -554,6 +554,7 @@
{
return HidClassFDO_RemoveDevice(DeviceObject, Irp);
}
+ case IRP_MN_QUERY_REMOVE_DEVICE:
case IRP_MN_QUERY_STOP_DEVICE:
{
//
@@ -567,6 +568,7 @@
IoSkipCurrentIrpStackLocation(Irp);
return
IoCallDriver(FDODeviceExtension->Common.HidDeviceExtension.NextDeviceObject, Irp);
}
+ case IRP_MN_CANCEL_REMOVE_DEVICE:
case IRP_MN_CANCEL_STOP_DEVICE:
{
//
Modified: branches/usb-bringup-trunk/drivers/hid/hidusb/hidusb.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/hid/h…
==============================================================================
--- branches/usb-bringup-trunk/drivers/hid/hidusb/hidusb.c [iso-8859-1] (original)
+++ branches/usb-bringup-trunk/drivers/hid/hidusb/hidusb.c [iso-8859-1] Fri Feb 3
22:59:53 2012
@@ -1561,19 +1561,41 @@
}
//
+ // delete and detach device
+ //
+ IoDetachDevice(DeviceExtension->NextDeviceObject);
+ IoDeleteDevice(DeviceObject);
+
+ return Status;
+ }
+ case IRP_MN_QUERY_PNP_DEVICE_STATE:
+ {
+ //
+ // device can not be disabled
+ //
+ Irp->IoStatus.Information |= PNP_DEVICE_NOT_DISABLEABLE;
+
+ //
+ // pass request to next request
+ //
+ IoSkipCurrentIrpStackLocation(Irp);
+ Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
+
+ //
// done
//
return Status;
}
- case IRP_MN_QUERY_PNP_DEVICE_STATE:
- {
- //
- // device can not be disabled
- //
- Irp->IoStatus.Information |= PNP_DEVICE_NOT_DISABLEABLE;
-
- //
- // pass request to next request
+ case IRP_MN_QUERY_STOP_DEVICE:
+ case IRP_MN_QUERY_REMOVE_DEVICE:
+ {
+ //
+ // we're fine with it
+ //
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+
+ //
+ // pass request to next driver
//
IoSkipCurrentIrpStackLocation(Irp);
Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
Modified: branches/usb-bringup-trunk/drivers/hid/kbdhid/kbdhid.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/hid/k…
==============================================================================
--- branches/usb-bringup-trunk/drivers/hid/kbdhid/kbdhid.c [iso-8859-1] (original)
+++ branches/usb-bringup-trunk/drivers/hid/kbdhid/kbdhid.c [iso-8859-1] Fri Feb 3
22:59:53 2012
@@ -737,7 +737,11 @@
IoStack = IoGetCurrentIrpStackLocation(Irp);
DPRINT1("[KBDHID] IRP_MJ_PNP Request: %x\n", IoStack->MinorFunction);
- if (IoStack->MinorFunction == IRP_MN_STOP_DEVICE || IoStack->MinorFunction ==
IRP_MN_CANCEL_REMOVE_DEVICE || IoStack->MinorFunction == IRP_MN_QUERY_STOP_DEVICE ||
IoStack->MinorFunction == IRP_MN_CANCEL_STOP_DEVICE)
+ if (IoStack->MinorFunction == IRP_MN_STOP_DEVICE ||
+ IoStack->MinorFunction == IRP_MN_CANCEL_REMOVE_DEVICE ||
+ IoStack->MinorFunction == IRP_MN_QUERY_STOP_DEVICE ||
+ IoStack->MinorFunction == IRP_MN_CANCEL_STOP_DEVICE ||
+ IoStack->MinorFunction == IRP_MN_QUERY_REMOVE_DEVICE)
{
/* indicate success */
Irp->IoStatus.Status = STATUS_SUCCESS;
Modified: branches/usb-bringup-trunk/drivers/hid/mouhid/mouhid.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/hid/m…
==============================================================================
--- branches/usb-bringup-trunk/drivers/hid/mouhid/mouhid.c [iso-8859-1] (original)
+++ branches/usb-bringup-trunk/drivers/hid/mouhid/mouhid.c [iso-8859-1] Fri Feb 3
22:59:53 2012
@@ -788,7 +788,11 @@
IoStack = IoGetCurrentIrpStackLocation(Irp);
DPRINT1("[MOUHID] IRP_MJ_PNP Request: %x\n", IoStack->MinorFunction);
- if (IoStack->MinorFunction == IRP_MN_STOP_DEVICE || IoStack->MinorFunction ==
IRP_MN_CANCEL_REMOVE_DEVICE || IoStack->MinorFunction == IRP_MN_QUERY_STOP_DEVICE ||
IoStack->MinorFunction == IRP_MN_CANCEL_STOP_DEVICE)
+ if (IoStack->MinorFunction == IRP_MN_STOP_DEVICE ||
+ IoStack->MinorFunction == IRP_MN_CANCEL_REMOVE_DEVICE ||
+ IoStack->MinorFunction == IRP_MN_QUERY_STOP_DEVICE ||
+ IoStack->MinorFunction == IRP_MN_CANCEL_STOP_DEVICE ||
+ IoStack->MinorFunction == IRP_MN_QUERY_REMOVE_DEVICE)
{
/* indicate success */
Irp->IoStatus.Status = STATUS_SUCCESS;
Modified: branches/usb-bringup-trunk/drivers/usb/usbccgp/fdo.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/usb/u…
==============================================================================
--- branches/usb-bringup-trunk/drivers/usb/usbccgp/fdo.c [iso-8859-1] (original)
+++ branches/usb-bringup-trunk/drivers/usb/usbccgp/fdo.c [iso-8859-1] Fri Feb 3 22:59:53
2012
@@ -481,6 +481,20 @@
}
break;
}
+ case IRP_MN_QUERY_REMOVE_DEVICE:
+ case IRP_MN_QUERY_STOP_DEVICE:
+ {
+ //
+ // sure
+ //
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+
+ //
+ // forward irp to next device object
+ //
+ IoSkipCurrentIrpStackLocation(Irp);
+ return IoCallDriver(FDODeviceExtension->NextDeviceObject, Irp);
+ }
default:
{
//
Modified: branches/usb-bringup-trunk/drivers/usb/usbccgp/pdo.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/usb/u…
==============================================================================
--- branches/usb-bringup-trunk/drivers/usb/usbccgp/pdo.c [iso-8859-1] (original)
+++ branches/usb-bringup-trunk/drivers/usb/usbccgp/pdo.c [iso-8859-1] Fri Feb 3 22:59:53
2012
@@ -391,6 +391,15 @@
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_SUCCESS;
}
+ case IRP_MN_QUERY_REMOVE_DEVICE:
+ case IRP_MN_QUERY_STOP_DEVICE:
+ {
+ //
+ // sure
+ //
+ Status = STATUS_SUCCESS;
+ break;
+ }
case IRP_MN_START_DEVICE:
{
//
@@ -406,6 +415,7 @@
// do nothing
//
Status = Irp->IoStatus.Status;
+ break;
}
}
Modified: branches/usb-bringup-trunk/drivers/usb/usbehci_new/hub_controller.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/usb/u…
==============================================================================
--- branches/usb-bringup-trunk/drivers/usb/usbehci_new/hub_controller.cpp [iso-8859-1]
(original)
+++ branches/usb-bringup-trunk/drivers/usb/usbehci_new/hub_controller.cpp [iso-8859-1] Fri
Feb 3 22:59:53 2012
@@ -432,6 +432,15 @@
// register device interface
//
Status = SetDeviceInterface(TRUE);
+ break;
+ }
+ case IRP_MN_QUERY_STOP_DEVICE:
+ case IRP_MN_QUERY_REMOVE_DEVICE:
+ {
+ //
+ // sure
+ //
+ Status = STATUS_SUCCESS;
break;
}
case IRP_MN_QUERY_ID:
Modified: branches/usb-bringup-trunk/drivers/usb/usbhub_new/fdo.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/usb/u…
==============================================================================
--- branches/usb-bringup-trunk/drivers/usb/usbhub_new/fdo.c [iso-8859-1] (original)
+++ branches/usb-bringup-trunk/drivers/usb/usbhub_new/fdo.c [iso-8859-1] Fri Feb 3
22:59:53 2012
@@ -1883,6 +1883,22 @@
}
break;
}
+ case IRP_MN_QUERY_REMOVE_DEVICE:
+ case IRP_MN_QUERY_STOP_DEVICE:
+ {
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ return ForwardIrpAndForget(DeviceObject, Irp);
+ }
+ case IRP_MN_REMOVE_DEVICE:
+ {
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+
+ IoDetachDevice(HubDeviceExtension->LowerDeviceObject);
+ IoDeleteDevice(DeviceObject);
+
+ return STATUS_SUCCESS;
+ }
case IRP_MN_QUERY_BUS_INFORMATION:
{
DPRINT1("IRP_MN_QUERY_BUS_INFORMATION\n");
Modified: branches/usb-bringup-trunk/drivers/usb/usbhub_new/pdo.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/usb/u…
==============================================================================
--- branches/usb-bringup-trunk/drivers/usb/usbhub_new/pdo.c [iso-8859-1] (original)
+++ branches/usb-bringup-trunk/drivers/usb/usbhub_new/pdo.c [iso-8859-1] Fri Feb 3
22:59:53 2012
@@ -586,6 +586,14 @@
IoDeleteDevice(DeviceObject);
return STATUS_SUCCESS;
}
+ case IRP_MN_QUERY_STOP_DEVICE:
+ case IRP_MN_QUERY_REMOVE_DEVICE:
+ {
+ /* Sure, no problem */
+ Status = STATUS_SUCCESS;
+ Information = 0;
+ break;
+ }
default:
{
DPRINT1("PDO IRP_MJ_PNP / unknown minor function 0x%lx\n",
MinorFunction);
Modified: branches/usb-bringup-trunk/drivers/usb/usbohci/hub_controller.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/usb/u…
==============================================================================
--- branches/usb-bringup-trunk/drivers/usb/usbohci/hub_controller.cpp [iso-8859-1]
(original)
+++ branches/usb-bringup-trunk/drivers/usb/usbohci/hub_controller.cpp [iso-8859-1] Fri Feb
3 22:59:53 2012
@@ -435,6 +435,15 @@
// register device interface
//
Status = SetDeviceInterface(TRUE);
+ break;
+ }
+ case IRP_MN_QUERY_STOP_DEVICE:
+ case IRP_MN_QUERY_REMOVE_DEVICE:
+ {
+ //
+ // sure
+ //
+ Status = STATUS_SUCCESS;
break;
}
case IRP_MN_QUERY_ID:
Modified: branches/usb-bringup-trunk/drivers/usb/usbstor/fdo.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/usb/u…
==============================================================================
--- branches/usb-bringup-trunk/drivers/usb/usbstor/fdo.c [iso-8859-1] (original)
+++ branches/usb-bringup-trunk/drivers/usb/usbstor/fdo.c [iso-8859-1] Fri Feb 3 22:59:53
2012
@@ -339,9 +339,11 @@
break;
}
case IRP_MN_STOP_DEVICE:
+ {
DPRINT1("USBSTOR_FdoHandlePnp: IRP_MN_STOP_DEVICE
unimplemented\n");
Status = STATUS_NOT_SUPPORTED;
break;
+ }
case IRP_MN_REMOVE_DEVICE:
{
DPRINT1("IRP_MN_REMOVE_DEVICE\n");
@@ -356,6 +358,29 @@
IoSkipCurrentIrpStackLocation(Irp);
return IoCallDriver(DeviceExtension->LowerDeviceObject, Irp);
}
+ case IRP_MN_QUERY_STOP_DEVICE:
+ case IRP_MN_QUERY_REMOVE_DEVICE:
+ {
+ //
+ // we can if nothing is pending
+ //
+ if (DeviceExtension->IrpPendingCount != 0 ||
+ DeviceExtension->ActiveSrb != NULL)
+ {
+ /* We have pending requests */
+ DPRINT1("Failing removal/stop request due to pending requests
present\n");
+ Status = STATUS_UNSUCCESSFUL;
+ }
+ else
+ {
+ /* We're all clear */
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+
+ IoSkipCurrentIrpStackLocation(Irp);
+ return IoCallDriver(DeviceExtension->LowerDeviceObject, Irp);
+ }
+ break;
+ }
case IRP_MN_START_DEVICE:
{
Status = USBSTOR_FdoHandleStartDevice(DeviceObject, DeviceExtension, Irp);
Modified: branches/usb-bringup-trunk/drivers/usb/usbstor/pdo.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/usb/u…
==============================================================================
--- branches/usb-bringup-trunk/drivers/usb/usbstor/pdo.c [iso-8859-1] (original)
+++ branches/usb-bringup-trunk/drivers/usb/usbstor/pdo.c [iso-8859-1] Fri Feb 3 22:59:53
2012
@@ -873,6 +873,18 @@
}
break;
}
+ case IRP_MN_QUERY_REMOVE_DEVICE:
+ case IRP_MN_QUERY_STOP_DEVICE:
+ {
+ //
+ // if we're not claimed it's ok
+ //
+ if (DeviceExtension->Claimed)
+ Status = STATUS_UNSUCCESSFUL;
+ else
+ Status = STATUS_SUCCESS;
+ break;
+ }
case IRP_MN_START_DEVICE:
{
//