https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e693d5ffc08e945e0d3d3c...
commit e693d5ffc08e945e0d3d3c4b7172d3f2b79e5f0e Author: Timo Kreuzer timo.kreuzer@reactos.org AuthorDate: Mon Oct 5 15:43:47 2020 +0200 Commit: Timo Kreuzer timo.kreuzer@reactos.org CommitDate: Fri May 28 22:29:44 2021 +0200
[USBPORT] Make unload work --- drivers/usb/usbport/pnp.c | 2 +- drivers/usb/usbport/usbport.c | 22 ++++++++++++++++++++++ drivers/usb/usbport/usbport.h | 8 +++++++- 3 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/usbport/pnp.c b/drivers/usb/usbport/pnp.c index 545b75e8201..b744857c94b 100644 --- a/drivers/usb/usbport/pnp.c +++ b/drivers/usb/usbport/pnp.c @@ -490,7 +490,6 @@ NTAPI USBPORT_StopDevice(IN PDEVICE_OBJECT FdoDevice) { DPRINT1("USBPORT_StopDevice: UNIMPLEMENTED. FIXME\n"); - DbgBreakPoint(); return STATUS_SUCCESS; }
@@ -901,6 +900,7 @@ USBPORT_StartDevice(IN PDEVICE_OBJECT FdoDevice, return Status;
ExitWithError: + USBPORT_StopWorkerThread(FdoDevice); USBPORT_StopDevice(FdoDevice);
DPRINT1("USBPORT_StartDevice: ExitWithError Status - %lx\n", Status); diff --git a/drivers/usb/usbport/usbport.c b/drivers/usb/usbport/usbport.c index 226bc6815aa..6fc6d6f155e 100644 --- a/drivers/usb/usbport/usbport.c +++ b/drivers/usb/usbport/usbport.c @@ -1390,6 +1390,11 @@ USBPORT_WorkerThread(IN PVOID StartContext) FALSE, NULL);
+ if (FdoExtension->Flags & USBPORT_FLAG_WORKER_THREAD_EXIT) + { + break; + } + KeQuerySystemTime(&NewTime);
KeAcquireSpinLock(&FdoExtension->WorkerThreadEventSpinLock, &OldIrql); @@ -1445,6 +1450,23 @@ USBPORT_CreateWorkerThread(IN PDEVICE_OBJECT FdoDevice) return Status; }
+VOID +NTAPI +USBPORT_StopWorkerThread(IN PDEVICE_OBJECT FdoDevice) +{ + PUSBPORT_DEVICE_EXTENSION FdoExtension; + NTSTATUS Status; + + DPRINT("USBPORT_StopWorkerThread ... \n"); + + FdoExtension = FdoDevice->DeviceExtension; + + FdoExtension->Flags |= USBPORT_FLAG_WORKER_THREAD_EXIT; + USBPORT_SignalWorkerThread(FdoDevice); + Status = ZwWaitForSingleObject(FdoExtension->WorkerThreadHandle, FALSE, NULL); + NT_ASSERT(Status == STATUS_SUCCESS); +} + VOID NTAPI USBPORT_SynchronizeControllersStart(IN PDEVICE_OBJECT FdoDevice) diff --git a/drivers/usb/usbport/usbport.h b/drivers/usb/usbport/usbport.h index 6ec826afede..9240c64545c 100644 --- a/drivers/usb/usbport/usbport.h +++ b/drivers/usb/usbport/usbport.h @@ -8,7 +8,7 @@ #ifndef USBPORT_H__ #define USBPORT_H__
-#include <ntddk.h> +#include <ntifs.h> #include <windef.h> #include <stdio.h> #include <wdmguid.h> @@ -67,6 +67,7 @@ #define USBPORT_FLAG_HC_STARTED 0x00000002 #define USBPORT_FLAG_HC_POLLING 0x00000004 #define USBPORT_FLAG_WORKER_THREAD_ON 0x00000008 +#define USBPORT_FLAG_WORKER_THREAD_EXIT 0x00000010 #define USBPORT_FLAG_HC_SUSPEND 0x00000100 #define USBPORT_FLAG_INTERRUPT_ENABLED 0x00000400 #define USBPORT_FLAG_SELECTIVE_SUSPEND 0x00000800 @@ -595,6 +596,11 @@ NTAPI USBPORT_CreateWorkerThread( IN PDEVICE_OBJECT FdoDevice);
+VOID +NTAPI +USBPORT_StopWorkerThread( + IN PDEVICE_OBJECT FdoDevice); + BOOLEAN NTAPI USBPORT_StartTimer(