From e33d8f1ee57262c956859b200b468999c3dfe0d8 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 26 Jan 2012 03:27:22 +0000 Subject: [PATCH] [HIDCLASS] - Implement IRP_MN_REMOVE_DEVICE for FDOs and PDOs - USB mice will now work after being disconnected then reconnected svn path=/branches/usb-bringup-trunk/; revision=55194 --- drivers/hid/hidclass/fdo.c | 15 ++++++++++++--- drivers/hid/hidclass/pdo.c | 18 +++++++++++------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/drivers/hid/hidclass/fdo.c b/drivers/hid/hidclass/fdo.c index d6844315ed6..7604d5104e8 100644 --- a/drivers/hid/hidclass/fdo.c +++ b/drivers/hid/hidclass/fdo.c @@ -384,9 +384,18 @@ HidClassFDO_RemoveDevice( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) { - UNIMPLEMENTED - ASSERT(FALSE); - return STATUS_NOT_IMPLEMENTED; + PHIDCLASS_FDO_EXTENSION FDODeviceExtension = DeviceObject->DeviceExtension; + NTSTATUS Status; + + /* Pass the IRP down */ + IoSkipCurrentIrpStackLocation(Irp); + Status = IoCallDriver(FDODeviceExtension->Common.HidDeviceExtension.NextDeviceObject, Irp); + + /* Now teardown our portion of the device stack */ + IoDetachDevice(FDODeviceExtension->Common.HidDeviceExtension.NextDeviceObject); + IoDeleteDevice(DeviceObject); + + return Status; } NTSTATUS diff --git a/drivers/hid/hidclass/pdo.c b/drivers/hid/hidclass/pdo.c index 492b72ba215..e0dc735d0a5 100644 --- a/drivers/hid/hidclass/pdo.c +++ b/drivers/hid/hidclass/pdo.c @@ -514,14 +514,18 @@ HidClassPDO_PnP( } case IRP_MN_REMOVE_DEVICE: { - DPRINT1("[HIDCLASS] PDO IRP_MN_REMOVE_DEVICE not implemented\n"); - ASSERT(FALSE); + /* Disable the device interface */ + if (PDODeviceExtension->DeviceInterface.Length != 0) + IoSetDeviceInterfaceState(&PDODeviceExtension->DeviceInterface, FALSE); - // - // do nothing - // - Status = STATUS_SUCCESS; //Irp->IoStatus.Status; - break; + /* Complete the IRP */ + Irp->IoStatus.Status = STATUS_SUCCESS; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + + /* Delete our device object*/ + IoDeleteDevice(DeviceObject); + + return STATUS_SUCCESS; } case IRP_MN_QUERY_INTERFACE: {