Author: janderwald
Date: Tue Feb 21 03:03:27 2012
New Revision: 55775
URL:
http://svn.reactos.org/svn/reactos?rev=55775&view=rev
Log:
[USBCCGP]
- Send unconfigure request when the device is removed
[USBOHCI]
- Handle unconfigure request
Modified:
trunk/reactos/drivers/usb/usbccgp/fdo.c
trunk/reactos/drivers/usb/usbohci/usb_device.cpp
Modified: trunk/reactos/drivers/usb/usbccgp/fdo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbccgp/fdo.c?…
==============================================================================
--- trunk/reactos/drivers/usb/usbccgp/fdo.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/usb/usbccgp/fdo.c [iso-8859-1] Tue Feb 21 03:03:27 2012
@@ -409,6 +409,52 @@
}
NTSTATUS
+FDO_CloseConfiguration(
+ IN PDEVICE_OBJECT DeviceObject)
+{
+ NTSTATUS Status;
+ PURB Urb;
+ PFDO_DEVICE_EXTENSION FDODeviceExtension;
+
+ // get device extension
+ FDODeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+ ASSERT(FDODeviceExtension->Common.IsFDO);
+
+ //
+ // now allocate the urb
+ //
+ Urb =
USBD_CreateConfigurationRequestEx(FDODeviceExtension->ConfigurationDescriptor,
FDODeviceExtension->InterfaceList);
+ if (!Urb)
+ {
+ //
+ // no memory
+ //
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ //
+ // clear configuration descriptor to make it an unconfigure request
+ //
+ Urb->UrbSelectConfiguration.ConfigurationDescriptor = NULL;
+
+ //
+ // submit urb
+ //
+ Status = USBCCGP_SyncUrbRequest(FDODeviceExtension->NextDeviceObject, Urb);
+ if (!NT_SUCCESS(Status))
+ {
+ //
+ // failed to set configuration
+ //
+ DPRINT1("USBCCGP_SyncUrbRequest failed to unconfigure device\n",
Status);
+ }
+
+ ExFreePool(Urb);
+ return Status;
+}
+
+
+NTSTATUS
FDO_HandlePnp(
PDEVICE_OBJECT DeviceObject,
PIRP Irp)
@@ -429,6 +475,12 @@
{
case IRP_MN_REMOVE_DEVICE:
{
+ //
+ // unconfigure device
+ //
+ DPRINT1("[USBCCGP] FDO IRP_MN_REMOVE\n");
+ FDO_CloseConfiguration(DeviceObject);
+
/* Send the IRP down the stack */
Status = USBCCGP_SyncForwardIrp(FDODeviceExtension->NextDeviceObject,
Irp);
if (NT_SUCCESS(Status))
Modified: trunk/reactos/drivers/usb/usbohci/usb_device.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbohci/usb_de…
==============================================================================
--- trunk/reactos/drivers/usb/usbohci/usb_device.cpp [iso-8859-1] (original)
+++ trunk/reactos/drivers/usb/usbohci/usb_device.cpp [iso-8859-1] Tue Feb 21 03:03:27
2012
@@ -1103,29 +1103,48 @@
ULONG InterfaceIndex, PipeIndex;
USB_DEFAULT_PIPE_SETUP_PACKET CtrlSetup;
NTSTATUS Status;
-
- //
- // sanity checks
- //
- ASSERT(ConfigurationDescriptor->iConfiguration <
m_DeviceDescriptor.bNumConfigurations);
- ASSERT(ConfigurationDescriptor->iConfiguration ==
m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].ConfigurationDescriptor->iConfiguration);
-
- //
- // sanity check
- //
- ASSERT(ConfigurationDescriptor->bNumInterfaces <=
m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].ConfigurationDescriptor->bNumInterfaces);
+ UCHAR bConfigurationValue = 0;
+
+ if (ConfigurationDescriptor)
+ {
+ //
+ // sanity checks
+ //
+ ASSERT(ConfigurationDescriptor->iConfiguration <
m_DeviceDescriptor.bNumConfigurations);
+ ASSERT(ConfigurationDescriptor->iConfiguration ==
m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].ConfigurationDescriptor->iConfiguration);
+
+ //
+ // sanity check
+ //
+ ASSERT(ConfigurationDescriptor->bNumInterfaces <=
m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].ConfigurationDescriptor->bNumInterfaces);
+
+ //
+ // get configuration value
+ //
+ bConfigurationValue = ConfigurationDescriptor->bConfigurationValue;
+ }
//
// now build setup packet
//
RtlZeroMemory(&CtrlSetup, sizeof(USB_DEFAULT_PIPE_SETUP_PACKET));
CtrlSetup.bRequest = USB_REQUEST_SET_CONFIGURATION;
- CtrlSetup.wValue.W = ConfigurationDescriptor->bConfigurationValue;
+ CtrlSetup.wValue.W = bConfigurationValue;
//
// select configuration
//
Status = CommitSetupPacket(&CtrlSetup, 0, 0, 0);
+
+ if (!ConfigurationDescriptor)
+ {
+ //
+ // unconfigure request
+ //
+ DPRINT1("CUsbDevice::SelectConfiguration Unconfigure Request Status
%x\n", Status);
+ m_ConfigurationIndex = 0;
+ return Status;
+ }
//
// informal debug print