[ros-diffs] [janderwald] 55411: [HIDCLASS] - Remove PDO from pdo list when it is destroyed - Handle IRP_MN_QUERY_REMOVE_DEVICE, IRP_MN_CANCEL_STOP_DEVICE, IRP_MN_QUERY_STOP_DEVICE, IRP_MN_CANCEL_REMOVE_DEVICE ...

janderwald at svn.reactos.org janderwald at svn.reactos.org
Sat Feb 4 14:10:19 UTC 2012


Author: janderwald
Date: Sat Feb  4 14:10:18 2012
New Revision: 55411

URL: http://svn.reactos.org/svn/reactos?rev=55411&view=rev
Log:
[HIDCLASS]
- Remove PDO from pdo list when it is destroyed
- Handle IRP_MN_QUERY_REMOVE_DEVICE, IRP_MN_CANCEL_STOP_DEVICE, IRP_MN_QUERY_STOP_DEVICE, IRP_MN_CANCEL_REMOVE_DEVICE
[HIDUSB]
- Add driver unload routine
[MOUHID]
- Wait for completion of pending irp
[USBHUB]
- Remove pdo from PDO list
- Handle IRP_MN_QUERY_DEVICE_RELATIONS
- Add stub driver unload routine
[USBOHCI]
- handle IRP_MN_REMOVE for FDO
- remove ASSERT

Modified:
    branches/usb-bringup-trunk/drivers/hid/hidclass/pdo.c
    branches/usb-bringup-trunk/drivers/hid/hidclass/precomp.h
    branches/usb-bringup-trunk/drivers/hid/hidusb/hidusb.c
    branches/usb-bringup-trunk/drivers/hid/mouhid/mouhid.c
    branches/usb-bringup-trunk/drivers/usb/usbhub_new/pdo.c
    branches/usb-bringup-trunk/drivers/usb/usbhub_new/usbhub.c
    branches/usb-bringup-trunk/drivers/usb/usbohci/hcd_controller.cpp
    branches/usb-bringup-trunk/drivers/usb/usbohci/usb_request.cpp

Modified: branches/usb-bringup-trunk/drivers/hid/hidclass/pdo.c
URL: http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/hid/hidclass/pdo.c?rev=55411&r1=55410&r2=55411&view=diff
==============================================================================
--- branches/usb-bringup-trunk/drivers/hid/hidclass/pdo.c [iso-8859-1] (original)
+++ branches/usb-bringup-trunk/drivers/hid/hidclass/pdo.c [iso-8859-1] Sat Feb  4 14:10:18 2012
@@ -344,7 +344,6 @@
     return STATUS_SUCCESS;
 }
 
-
 NTSTATUS
 HidClassPDO_PnP(
     IN PDEVICE_OBJECT DeviceObject,
@@ -355,6 +354,7 @@
     NTSTATUS Status;
     PPNP_BUS_INFORMATION BusInformation;
     PDEVICE_RELATIONS DeviceRelation;
+    ULONG Index;
 
     //
     // get device extension
@@ -532,6 +532,21 @@
             if (PDODeviceExtension->DeviceInterface.Length != 0)
                 IoSetDeviceInterfaceState(&PDODeviceExtension->DeviceInterface, FALSE);
 
+           //
+           // remove us from the fdo's pdo list
+           //
+           for(Index = 0; Index < PDODeviceExtension->FDODeviceExtension->DeviceRelations->Count; Index++)
+           {
+               if (PDODeviceExtension->FDODeviceExtension->DeviceRelations->Objects[Index] == DeviceObject)
+               {
+                   //
+                   // remove us
+                   //
+                   PDODeviceExtension->FDODeviceExtension->DeviceRelations->Objects[Index] = NULL;
+                   break;
+               }
+           }
+
             /* Complete the IRP */
             Irp->IoStatus.Status = STATUS_SUCCESS;
             IoCompleteRequest(Irp, IO_NO_INCREMENT);
@@ -550,6 +565,17 @@
             // do nothing
             //
             Status = Irp->IoStatus.Status;
+            break;
+        }
+        case IRP_MN_QUERY_REMOVE_DEVICE:
+        case IRP_MN_CANCEL_STOP_DEVICE:
+        case IRP_MN_QUERY_STOP_DEVICE:
+        case IRP_MN_CANCEL_REMOVE_DEVICE:
+        {
+            //
+            // no/op
+            //
+            Status = STATUS_SUCCESS;
             break;
         }
         default:
@@ -657,6 +683,7 @@
         PDODeviceExtension->Common.HidDeviceExtension.NextDeviceObject = FDODeviceExtension->Common.HidDeviceExtension.NextDeviceObject;
         PDODeviceExtension->Common.HidDeviceExtension.PhysicalDeviceObject = FDODeviceExtension->Common.HidDeviceExtension.PhysicalDeviceObject;
         PDODeviceExtension->Common.IsFDO = FALSE;
+        PDODeviceExtension->FDODeviceExtension = FDODeviceExtension;
         PDODeviceExtension->FDODeviceObject = DeviceObject;
         PDODeviceExtension->Common.DriverExtension = FDODeviceExtension->Common.DriverExtension;
         PDODeviceExtension->CollectionNumber = FDODeviceExtension->Common.DeviceDescription.CollectionDesc[Index].CollectionNumber;

Modified: branches/usb-bringup-trunk/drivers/hid/hidclass/precomp.h
URL: http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/hid/hidclass/precomp.h?rev=55411&r1=55410&r2=55411&view=diff
==============================================================================
--- branches/usb-bringup-trunk/drivers/hid/hidclass/precomp.h [iso-8859-1] (original)
+++ branches/usb-bringup-trunk/drivers/hid/hidclass/precomp.h [iso-8859-1] Sat Feb  4 14:10:18 2012
@@ -107,6 +107,11 @@
     //
     PDEVICE_OBJECT FDODeviceObject;
 
+    //
+    // fdo device extension
+    //
+    PHIDCLASS_FDO_EXTENSION FDODeviceExtension;
+
 }HIDCLASS_PDO_DEVICE_EXTENSION, *PHIDCLASS_PDO_DEVICE_EXTENSION;
 
 typedef struct __HIDCLASS_FILEOP_CONTEXT__

Modified: branches/usb-bringup-trunk/drivers/hid/hidusb/hidusb.c
URL: http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/hid/hidusb/hidusb.c?rev=55411&r1=55410&r2=55411&view=diff
==============================================================================
--- 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] Sat Feb  4 14:10:18 2012
@@ -1764,6 +1764,15 @@
     return STATUS_SUCCESS;
 }
 
+VOID
+NTAPI
+Hid_Unload(
+    IN PDRIVER_OBJECT DriverObject)
+{
+    UNIMPLEMENTED
+}
+
+
 NTSTATUS
 NTAPI
 DriverEntry(
@@ -1783,6 +1792,7 @@
     DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = HidSystemControl;
     DriverObject->MajorFunction[IRP_MJ_PNP] = HidPnp;
     DriverObject->DriverExtension->AddDevice = HidAddDevice;
+    DriverObject->DriverUnload = Hid_Unload;
 
     //
     // prepare registration info

Modified: branches/usb-bringup-trunk/drivers/hid/mouhid/mouhid.c
URL: http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/hid/mouhid/mouhid.c?rev=55411&r1=55410&r2=55411&view=diff
==============================================================================
--- 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] Sat Feb  4 14:10:18 2012
@@ -807,6 +807,9 @@
     {
         /* FIXME synchronization */
 
+        /* request stop */
+        DeviceExtension->StopReadReport = TRUE;
+
         /* cancel irp */
         IoCancelIrp(DeviceExtension->Irp);
 
@@ -819,9 +822,19 @@
         /* dispatch to lower device */
         Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
 
+        /* wait for completion of stop event */
+        KeWaitForSingleObject(&DeviceExtension->ReadCompletionEvent, Executive, KernelMode, FALSE, NULL);
+
+        /* free irp */
         IoFreeIrp(DeviceExtension->Irp);
+
+        /* detach device */
         IoDetachDevice(DeviceExtension->NextDeviceObject);
+
+        /* delete device */
         IoDeleteDevice(DeviceObject);
+
+        /* done */
         return Status;
     }
     else if (IoStack->MinorFunction == IRP_MN_START_DEVICE)

Modified: branches/usb-bringup-trunk/drivers/usb/usbhub_new/pdo.c
URL: http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/usb/usbhub_new/pdo.c?rev=55411&r1=55410&r2=55411&view=diff
==============================================================================
--- 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] Sat Feb  4 14:10:18 2012
@@ -485,6 +485,8 @@
     PIO_STACK_LOCATION Stack;
     ULONG_PTR Information = 0;
     PHUB_CHILDDEVICE_EXTENSION UsbChildExtension;
+    ULONG Index;
+    PDEVICE_RELATIONS DeviceRelation;
 
     UsbChildExtension = (PHUB_CHILDDEVICE_EXTENSION)DeviceObject->DeviceExtension;
     Stack = IoGetCurrentIrpStackLocation(Irp);
@@ -576,7 +578,21 @@
             DPRINT1("IRP_MJ_PNP / IRP_MN_REMOVE_DEVICE\n");
 
             /* Remove the device */
-            HubInterface->RemoveUsbDevice(HubDeviceExtension->UsbDInterface.BusContext, UsbChildExtension->UsbDeviceHandle, 0);
+            Status = HubInterface->RemoveUsbDevice(HubDeviceExtension->UsbDInterface.BusContext, UsbChildExtension->UsbDeviceHandle, 0);
+
+            /* FIXME handle error */
+            ASSERT(Status == STATUS_SUCCESS);
+
+            /* remove us from pdo list */
+            for(Index = 0; Index < USB_MAXCHILDREN; Index++)
+            {
+                if (HubDeviceExtension->ChildDeviceObject[Index] == DeviceObject)
+                {
+                    /* remove us */
+                    HubDeviceExtension->ChildDeviceObject[Index] = NULL;
+                    break;
+                }
+            }
 
             /* Complete the IRP */
             Irp->IoStatus.Status = STATUS_SUCCESS;
@@ -585,6 +601,35 @@
             /* Delete the device object */
             IoDeleteDevice(DeviceObject);
             return STATUS_SUCCESS;
+        }
+        case IRP_MN_QUERY_DEVICE_RELATIONS:
+        {
+            /* only target relations are supported */
+            if (Stack->Parameters.QueryDeviceRelations.Type != TargetDeviceRelation)
+            {
+                /* not supported */
+                Status = Irp->IoStatus.Status;
+                break;
+            }
+
+            /* allocate device relations */
+            DeviceRelation = (PDEVICE_RELATIONS)ExAllocatePool(NonPagedPool, sizeof(DEVICE_RELATIONS));
+            if (!DeviceRelation)
+            {
+                /* no memory */
+                Status = STATUS_INSUFFICIENT_RESOURCES;
+                break;
+            }
+
+            /* init device relation */
+            DeviceRelation->Count = 1;
+            DeviceRelation->Objects[0] = DeviceObject;
+            ObReferenceObject(DeviceRelation->Objects[0]);
+
+            /* store result */
+            Irp->IoStatus.Information = (ULONG_PTR)DeviceRelation;
+            Status = STATUS_SUCCESS;
+            break;
         }
         case IRP_MN_QUERY_STOP_DEVICE:
         case IRP_MN_QUERY_REMOVE_DEVICE:

Modified: branches/usb-bringup-trunk/drivers/usb/usbhub_new/usbhub.c
URL: http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/usb/usbhub_new/usbhub.c?rev=55411&r1=55410&r2=55411&view=diff
==============================================================================
--- branches/usb-bringup-trunk/drivers/usb/usbhub_new/usbhub.c [iso-8859-1] (original)
+++ branches/usb-bringup-trunk/drivers/usb/usbhub_new/usbhub.c [iso-8859-1] Sat Feb  4 14:10:18 2012
@@ -183,12 +183,23 @@
     return STATUS_NOT_SUPPORTED;
 }
 
+VOID
+NTAPI
+USBHUB_Unload(
+    IN PDRIVER_OBJECT DriverObject)
+{
+    UNIMPLEMENTED
+}
+
+
 NTSTATUS NTAPI
 DriverEntry(
     IN PDRIVER_OBJECT DriverObject,
     IN PUNICODE_STRING RegistryPath)
 {
     DriverObject->DriverExtension->AddDevice = USBHUB_AddDevice;
+    DriverObject->DriverUnload = USBHUB_Unload;
+
     DPRINT1("USBHUB: DriverEntry\n");
 
     DriverObject->MajorFunction[IRP_MJ_CREATE] = USBHUB_Create;

Modified: branches/usb-bringup-trunk/drivers/usb/usbohci/hcd_controller.cpp
URL: http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/usb/usbohci/hcd_controller.cpp?rev=55411&r1=55410&r2=55411&view=diff
==============================================================================
--- branches/usb-bringup-trunk/drivers/usb/usbohci/hcd_controller.cpp [iso-8859-1] (original)
+++ branches/usb-bringup-trunk/drivers/usb/usbohci/hcd_controller.cpp [iso-8859-1] Sat Feb  4 14:10:18 2012
@@ -531,7 +531,19 @@
                 // stop lower device
                 //
                 Status = SyncForwardIrp(m_NextDeviceObject, Irp);
-            }
+                if (NT_SUCCESS(Status))
+                {
+                    //
+                    // detach device
+                    //
+                    IoDetachDevice(m_NextDeviceObject);
+                    IoDeleteDevice(DeviceObject);
+                }
+
+            }
+
+
+
             break;
         }
         case IRP_MN_QUERY_REMOVE_DEVICE:

Modified: branches/usb-bringup-trunk/drivers/usb/usbohci/usb_request.cpp
URL: http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/usb/usbohci/usb_request.cpp?rev=55411&r1=55410&r2=55411&view=diff
==============================================================================
--- branches/usb-bringup-trunk/drivers/usb/usbohci/usb_request.cpp [iso-8859-1] (original)
+++ branches/usb-bringup-trunk/drivers/usb/usbohci/usb_request.cpp [iso-8859-1] Sat Feb  4 14:10:18 2012
@@ -1672,11 +1672,6 @@
 
         while(TransferDescriptor)
         {
-             //
-             // the descriptor must have been processed
-             //
-            ASSERT(OHCI_TD_GET_CONDITION_CODE(TransferDescriptor->Flags) != OHCI_TD_CONDITION_NOT_ACCESSED);
-
             //
             // get condition code
             //




More information about the Ros-diffs mailing list