mirror of
https://github.com/reactos/reactos.git
synced 2025-04-26 16:40:27 +00:00
[USBCCGP]
- Send unconfigure request when the device is removed [USBOHCI] - Handle unconfigure request svn path=/trunk/; revision=55775
This commit is contained in:
parent
5b71379204
commit
b398f3fe30
2 changed files with 81 additions and 10 deletions
|
@ -408,6 +408,52 @@ FDO_StartDevice(
|
|||
return Status;
|
||||
}
|
||||
|
||||
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,
|
||||
|
@ -429,6 +475,12 @@ FDO_HandlePnp(
|
|||
{
|
||||
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))
|
||||
|
|
|
@ -1103,30 +1103,49 @@ CUSBDevice::SelectConfiguration(
|
|||
ULONG InterfaceIndex, PipeIndex;
|
||||
USB_DEFAULT_PIPE_SETUP_PACKET CtrlSetup;
|
||||
NTSTATUS Status;
|
||||
UCHAR bConfigurationValue = 0;
|
||||
|
||||
//
|
||||
// sanity checks
|
||||
//
|
||||
ASSERT(ConfigurationDescriptor->iConfiguration < m_DeviceDescriptor.bNumConfigurations);
|
||||
ASSERT(ConfigurationDescriptor->iConfiguration == m_ConfigurationDescriptors[ConfigurationDescriptor->iConfiguration].ConfigurationDescriptor->iConfiguration);
|
||||
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);
|
||||
//
|
||||
// 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
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue