https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7ed1883c8ebf02ffa1d9e…
commit 7ed1883c8ebf02ffa1d9ea8fe11b9a0f4e5c7551
Author: Victor Perevertkin <victor.perevertkin(a)reactos.org>
AuthorDate: Tue Jan 4 03:56:52 2022 +0300
Commit: Victor Perevertkin <victor.perevertkin(a)reactos.org>
CommitDate: Wed Jan 5 02:17:56 2022 +0300
[DRIVERS] Use IoForwardIrpSynchronously in drivers
Instead of having an own routine in each driver
IoForwardIrpSynchronously can be used.
---
drivers/bus/pci/fdo.c | 53 +++++---------------------
drivers/input/i8042prt/i8042prt.h | 2 -
drivers/input/i8042prt/misc.c | 41 --------------------
drivers/input/i8042prt/pnp.c | 23 ++++++++----
drivers/input/kbdclass/kbdclass.c | 27 +++++++++++---
drivers/input/kbdclass/kbdclass.h | 5 ---
drivers/input/kbdclass/misc.c | 41 --------------------
drivers/input/mouclass/misc.c | 41 --------------------
drivers/input/mouclass/mouclass.c | 10 ++++-
drivers/input/mouclass/mouclass.h | 5 ---
drivers/input/sermouse/fdo.c | 16 ++++++--
drivers/input/sermouse/misc.c | 38 -------------------
drivers/input/sermouse/sermouse.h | 5 ---
drivers/ksfilter/ks/device.c | 63 ++++++++++---------------------
drivers/ksfilter/ks/ksfunc.h | 5 ---
drivers/ksfilter/ks/misc.c | 51 -------------------------
drivers/parallel/parport/fdo.c | 21 +++++++----
drivers/parallel/parport/misc.c | 44 ----------------------
drivers/parallel/parport/parport.h | 4 --
drivers/processor/processr/misc.c | 48 ------------------------
drivers/processor/processr/pnp.c | 17 ++++++---
drivers/processor/processr/processr.h | 6 ---
drivers/serial/serenum/fdo.c | 16 ++++++--
drivers/serial/serenum/misc.c | 44 ----------------------
drivers/serial/serial/misc.c | 40 --------------------
drivers/serial/serial/pnp.c | 26 +++++++++----
drivers/serial/serial/serial.h | 5 ---
drivers/storage/floppy/fdc/fdo.c | 64 +++++++-------------------------
drivers/storage/ide/pciidex/fdo.c | 16 ++++++--
drivers/storage/ide/pciidex/misc.c | 40 --------------------
drivers/storage/ide/pciidex/pciidex.h | 12 ------
drivers/storage/port/storport/fdo.c | 12 +++++-
drivers/storage/port/storport/misc.c | 41 --------------------
drivers/storage/port/storport/precomp.h | 5 ---
drivers/usb/usbccgp/fdo.c | 23 +++++++++---
drivers/usb/usbccgp/misc.c | 40 --------------------
drivers/usb/usbccgp/pdo.c | 10 ++++-
drivers/usb/usbccgp/usbccgp.h | 6 ---
drivers/usb/usbstor/fdo.c | 7 +++-
drivers/usb/usbstor/misc.c | 23 ------------
drivers/usb/usbstor/pdo.c | 23 +++++++-----
drivers/usb/usbstor/usbstor.h | 12 ------
drivers/wdm/audio/legacy/stream/helper.c | 56 ----------------------------
drivers/wdm/audio/legacy/stream/pnp.c | 10 ++++-
drivers/wdm/audio/legacy/stream/stream.h | 7 ----
45 files changed, 238 insertions(+), 866 deletions(-)
diff --git a/drivers/bus/pci/fdo.c b/drivers/bus/pci/fdo.c
index 17a4c07c622..2eb5ef2012f 100644
--- a/drivers/bus/pci/fdo.c
+++ b/drivers/bus/pci/fdo.c
@@ -14,46 +14,6 @@
/*** PRIVATE *****************************************************************/
-static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion;
-
-static NTSTATUS NTAPI
-ForwardIrpAndWaitCompletion(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp,
- IN PVOID Context)
-{
- UNREFERENCED_PARAMETER(DeviceObject);
- if (Irp->PendingReturned)
- KeSetEvent((PKEVENT)Context, IO_NO_INCREMENT, FALSE);
- return STATUS_MORE_PROCESSING_REQUIRED;
-}
-
-NTSTATUS NTAPI
-ForwardIrpAndWait(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp)
-{
- KEVENT Event;
- NTSTATUS Status;
- PDEVICE_OBJECT LowerDevice =
((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Ldo;
- ASSERT(LowerDevice);
-
- KeInitializeEvent(&Event, NotificationEvent, FALSE);
- IoCopyCurrentIrpStackLocationToNext(Irp);
-
- IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE,
TRUE);
-
- Status = IoCallDriver(LowerDevice, Irp);
- if (Status == STATUS_PENDING)
- {
- Status = KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
- if (NT_SUCCESS(Status))
- Status = Irp->IoStatus.Status;
- }
-
- return Status;
-}
-
static NTSTATUS
FdoLocateChildDevice(
PPCI_DEVICE *Device,
@@ -524,9 +484,16 @@ FdoPnpControl(
#endif
case IRP_MN_START_DEVICE:
DPRINT("IRP_MN_START_DEVICE received\n");
- Status = ForwardIrpAndWait(DeviceObject, Irp);
- if (NT_SUCCESS(Status))
- Status = FdoStartDevice(DeviceObject, Irp);
+ Status = STATUS_UNSUCCESSFUL;
+
+ if (IoForwardIrpSynchronously(DeviceExtension->Ldo, Irp))
+ {
+ Status = Irp->IoStatus.Status;
+ if (NT_SUCCESS(Status))
+ {
+ Status = FdoStartDevice(DeviceObject, Irp);
+ }
+ }
Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
diff --git a/drivers/input/i8042prt/i8042prt.h b/drivers/input/i8042prt/i8042prt.h
index 71be9823265..758b0b2bb63 100644
--- a/drivers/input/i8042prt/i8042prt.h
+++ b/drivers/input/i8042prt/i8042prt.h
@@ -340,8 +340,6 @@ i8042StartPacket(
DRIVER_DISPATCH ForwardIrpAndForget;
-DRIVER_DISPATCH ForwardIrpAndWait;
-
NTSTATUS
DuplicateUnicodeString(
IN ULONG Flags,
diff --git a/drivers/input/i8042prt/misc.c b/drivers/input/i8042prt/misc.c
index 36927d50f05..29c39477f69 100644
--- a/drivers/input/i8042prt/misc.c
+++ b/drivers/input/i8042prt/misc.c
@@ -14,47 +14,6 @@
/* FUNCTIONS *****************************************************************/
-static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion;
-
-static NTSTATUS NTAPI
-ForwardIrpAndWaitCompletion(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp,
- IN PVOID Context)
-{
- UNREFERENCED_PARAMETER(DeviceObject);
- __analysis_assume(Context != NULL);
- if (Irp->PendingReturned)
- KeSetEvent(Context, IO_NO_INCREMENT, FALSE);
- return STATUS_MORE_PROCESSING_REQUIRED;
-}
-
-NTSTATUS NTAPI
-ForwardIrpAndWait(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp)
-{
- KEVENT Event;
- NTSTATUS Status;
- PDEVICE_OBJECT LowerDevice =
((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
- ASSERT(LowerDevice);
-
- KeInitializeEvent(&Event, NotificationEvent, FALSE);
- IoCopyCurrentIrpStackLocationToNext(Irp);
-
- IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE, TRUE);
-
- Status = IoCallDriver(LowerDevice, Irp);
- if (Status == STATUS_PENDING)
- {
- Status = KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
- if (NT_SUCCESS(Status))
- Status = Irp->IoStatus.Status;
- }
-
- return Status;
-}
-
NTSTATUS NTAPI
ForwardIrpAndForget(
IN PDEVICE_OBJECT DeviceObject,
diff --git a/drivers/input/i8042prt/pnp.c b/drivers/input/i8042prt/pnp.c
index e5fe57b2080..147ef3d3ac4 100644
--- a/drivers/input/i8042prt/pnp.c
+++ b/drivers/input/i8042prt/pnp.c
@@ -676,6 +676,7 @@ i8042Pnp(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
+ PFDO_DEVICE_EXTENSION FdoExtension;
PIO_STACK_LOCATION Stack;
ULONG MinorFunction;
I8042_DEVICE_TYPE DeviceType;
@@ -684,7 +685,8 @@ i8042Pnp(
Stack = IoGetCurrentIrpStackLocation(Irp);
MinorFunction = Stack->MinorFunction;
- DeviceType = ((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Type;
+ FdoExtension = DeviceObject->DeviceExtension;
+ DeviceType = FdoExtension->Type;
switch (MinorFunction)
{
@@ -695,12 +697,19 @@ i8042Pnp(
/* Call lower driver (if any) */
if (DeviceType != PhysicalDeviceObject)
{
- Status = ForwardIrpAndWait(DeviceObject, Irp);
- if (NT_SUCCESS(Status))
- Status = i8042PnpStartDevice(
- DeviceObject,
- Stack->Parameters.StartDevice.AllocatedResources,
- Stack->Parameters.StartDevice.AllocatedResourcesTranslated);
+ Status = STATUS_UNSUCCESSFUL;
+
+ if (IoForwardIrpSynchronously(FdoExtension->LowerDevice, Irp))
+ {
+ Status = Irp->IoStatus.Status;
+ if (NT_SUCCESS(Status))
+ {
+ Status = i8042PnpStartDevice(
+ DeviceObject,
+ Stack->Parameters.StartDevice.AllocatedResources,
+
Stack->Parameters.StartDevice.AllocatedResourcesTranslated);
+ }
+ }
}
else
Status = STATUS_SUCCESS;
diff --git a/drivers/input/kbdclass/kbdclass.c b/drivers/input/kbdclass/kbdclass.c
index 86f354c3240..ccf83532aaf 100644
--- a/drivers/input/kbdclass/kbdclass.c
+++ b/drivers/input/kbdclass/kbdclass.c
@@ -163,12 +163,21 @@ ClassDeviceControl(
while (Entry != Head)
{
PPORT_DEVICE_EXTENSION DevExt = CONTAINING_RECORD(Entry, PORT_DEVICE_EXTENSION,
ListEntry);
- NTSTATUS IntermediateStatus;
IoGetCurrentIrpStackLocation(Irp)->MajorFunction =
IRP_MJ_INTERNAL_DEVICE_CONTROL;
- IntermediateStatus = ForwardIrpAndWait(DevExt->DeviceObject, Irp);
- if (!NT_SUCCESS(IntermediateStatus))
- Status = IntermediateStatus;
+
+ if (IoForwardIrpSynchronously(DevExt->LowerDevice, Irp))
+ {
+ if (!NT_SUCCESS(Irp->IoStatus.Status))
+ {
+ Status = Irp->IoStatus.Status;
+ }
+ }
+ else
+ {
+ Status = STATUS_UNSUCCESSFUL;
+ }
+
Entry = Entry->Flink;
}
break;
@@ -836,7 +845,15 @@ ClassPnp(
switch (IrpSp->MinorFunction)
{
case IRP_MN_START_DEVICE:
- Status = ForwardIrpAndWait(DeviceObject, Irp);
+ if (IoForwardIrpSynchronously(DeviceExtension->LowerDevice, Irp))
+ {
+ Status = Irp->IoStatus.Status;
+ }
+ else
+ {
+ Status = STATUS_UNSUCCESSFUL;
+ }
+
if (NT_SUCCESS(Status))
{
InitializeObjectAttributes(&ObjectAttributes,
diff --git a/drivers/input/kbdclass/kbdclass.h b/drivers/input/kbdclass/kbdclass.h
index 6041dad2916..cfd6c41d17f 100644
--- a/drivers/input/kbdclass/kbdclass.h
+++ b/drivers/input/kbdclass/kbdclass.h
@@ -67,11 +67,6 @@ typedef struct _CLASS_DEVICE_EXTENSION
/* misc.c */
-NTSTATUS
-ForwardIrpAndWait(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp);
-
DRIVER_DISPATCH ForwardIrpAndForget;
NTSTATUS
diff --git a/drivers/input/kbdclass/misc.c b/drivers/input/kbdclass/misc.c
index 88e99e4b262..4a419df369e 100644
--- a/drivers/input/kbdclass/misc.c
+++ b/drivers/input/kbdclass/misc.c
@@ -11,47 +11,6 @@
#include <debug.h>
-static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion;
-
-static NTSTATUS NTAPI
-ForwardIrpAndWaitCompletion(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp,
- IN PVOID Context)
-{
- if (Irp->PendingReturned)
- KeSetEvent((PKEVENT)Context, IO_NO_INCREMENT, FALSE);
- return STATUS_MORE_PROCESSING_REQUIRED;
-}
-
-NTSTATUS
-ForwardIrpAndWait(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp)
-{
- PDEVICE_OBJECT LowerDevice;
- KEVENT Event;
- NTSTATUS Status;
-
- ASSERT(!((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsClassDO);
- LowerDevice =
((PPORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
-
- KeInitializeEvent(&Event, NotificationEvent, FALSE);
- IoCopyCurrentIrpStackLocationToNext(Irp);
-
- TRACE_(CLASS_NAME, "Calling lower device %p\n", LowerDevice);
- IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE, TRUE);
-
- Status = IoCallDriver(LowerDevice, Irp);
- if (Status == STATUS_PENDING)
- {
- Status = KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
- if (NT_SUCCESS(Status))
- Status = Irp->IoStatus.Status;
- }
-
- return Status;
-}
NTSTATUS NTAPI
ForwardIrpAndForget(
diff --git a/drivers/input/mouclass/misc.c b/drivers/input/mouclass/misc.c
index 93552d39cf8..c747558ec13 100644
--- a/drivers/input/mouclass/misc.c
+++ b/drivers/input/mouclass/misc.c
@@ -11,47 +11,6 @@
#include <debug.h>
-static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion;
-
-static NTSTATUS NTAPI
-ForwardIrpAndWaitCompletion(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp,
- IN PVOID Context)
-{
- if (Irp->PendingReturned)
- KeSetEvent((PKEVENT)Context, IO_NO_INCREMENT, FALSE);
- return STATUS_MORE_PROCESSING_REQUIRED;
-}
-
-NTSTATUS
-ForwardIrpAndWait(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp)
-{
- PDEVICE_OBJECT LowerDevice;
- KEVENT Event;
- NTSTATUS Status;
-
- ASSERT(!((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsClassDO);
- LowerDevice =
((PPORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
-
- KeInitializeEvent(&Event, NotificationEvent, FALSE);
- IoCopyCurrentIrpStackLocationToNext(Irp);
-
- TRACE_(CLASS_NAME, "Calling lower device %p\n", LowerDevice);
- IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE, TRUE);
-
- Status = IoCallDriver(LowerDevice, Irp);
- if (Status == STATUS_PENDING)
- {
- Status = KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
- if (NT_SUCCESS(Status))
- Status = Irp->IoStatus.Status;
- }
-
- return Status;
-}
NTSTATUS NTAPI
ForwardIrpAndForget(
diff --git a/drivers/input/mouclass/mouclass.c b/drivers/input/mouclass/mouclass.c
index dc694b4f9c3..f84dcc30238 100644
--- a/drivers/input/mouclass/mouclass.c
+++ b/drivers/input/mouclass/mouclass.c
@@ -812,7 +812,15 @@ ClassPnp(
switch (IrpSp->MinorFunction)
{
case IRP_MN_START_DEVICE:
- Status = ForwardIrpAndWait(DeviceObject, Irp);
+ if (IoForwardIrpSynchronously(DeviceExtension->LowerDevice, Irp))
+ {
+ Status = Irp->IoStatus.Status;
+ }
+ else
+ {
+ Status = STATUS_UNSUCCESSFUL;
+ }
+
if (NT_SUCCESS(Status))
{
InitializeObjectAttributes(&ObjectAttributes,
diff --git a/drivers/input/mouclass/mouclass.h b/drivers/input/mouclass/mouclass.h
index fcc877504bf..45f9c76021e 100644
--- a/drivers/input/mouclass/mouclass.h
+++ b/drivers/input/mouclass/mouclass.h
@@ -67,11 +67,6 @@ typedef struct _CLASS_DEVICE_EXTENSION
/* misc.c */
-NTSTATUS
-ForwardIrpAndWait(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp);
-
DRIVER_DISPATCH ForwardIrpAndForget;
NTSTATUS
diff --git a/drivers/input/sermouse/fdo.c b/drivers/input/sermouse/fdo.c
index 486abea139c..3b42e087f63 100644
--- a/drivers/input/sermouse/fdo.c
+++ b/drivers/input/sermouse/fdo.c
@@ -172,11 +172,21 @@ SermousePnp(
*/
case IRP_MN_START_DEVICE: /* 0x0 */
{
+ PSERMOUSE_DEVICE_EXTENSION DeviceExtension;
+
TRACE_(SERMOUSE, "IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
+ Status = STATUS_UNSUCCESSFUL;
+ DeviceExtension = DeviceObject->DeviceExtension;
+
/* Call lower driver */
- Status = ForwardIrpAndWait(DeviceObject, Irp);
- if (NT_SUCCESS(Status))
- Status = SermouseStartDevice(DeviceObject, Irp);
+ if (IoForwardIrpSynchronously(DeviceExtension->LowerDevice, Irp))
+ {
+ Status = Irp->IoStatus.Status;
+ if (NT_SUCCESS(Status))
+ {
+ Status = SermouseStartDevice(DeviceObject, Irp);
+ }
+ }
break;
}
case IRP_MN_QUERY_DEVICE_RELATIONS: /* 0x7 */
diff --git a/drivers/input/sermouse/misc.c b/drivers/input/sermouse/misc.c
index 9b8e74dbcec..704e49adb6f 100644
--- a/drivers/input/sermouse/misc.c
+++ b/drivers/input/sermouse/misc.c
@@ -10,44 +10,6 @@
#include <debug.h>
-static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion;
-
-static NTSTATUS NTAPI
-ForwardIrpAndWaitCompletion(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp,
- IN PVOID Context)
-{
- if (Irp->PendingReturned)
- KeSetEvent((PKEVENT)Context, IO_NO_INCREMENT, FALSE);
- return STATUS_MORE_PROCESSING_REQUIRED;
-}
-
-NTSTATUS
-ForwardIrpAndWait(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp)
-{
- PDEVICE_OBJECT LowerDevice =
((PSERMOUSE_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
- KEVENT Event;
- NTSTATUS Status;
-
- KeInitializeEvent(&Event, NotificationEvent, FALSE);
- IoCopyCurrentIrpStackLocationToNext(Irp);
-
- TRACE_(SERMOUSE, "Calling lower device %p\n", LowerDevice);
- IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE, TRUE);
-
- Status = IoCallDriver(LowerDevice, Irp);
- if (Status == STATUS_PENDING)
- {
- Status = KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
- if (NT_SUCCESS(Status))
- Status = Irp->IoStatus.Status;
- }
-
- return Status;
-}
NTSTATUS NTAPI
ForwardIrpAndForget(
diff --git a/drivers/input/sermouse/sermouse.h b/drivers/input/sermouse/sermouse.h
index 7cbd05cc788..d6d90852598 100644
--- a/drivers/input/sermouse/sermouse.h
+++ b/drivers/input/sermouse/sermouse.h
@@ -98,11 +98,6 @@ DRIVER_DISPATCH SermouseInternalDeviceControl;
/************************************ misc.c */
-NTSTATUS
-ForwardIrpAndWait(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp);
-
NTSTATUS NTAPI
ForwardIrpAndForget(
IN PDEVICE_OBJECT DeviceObject,
diff --git a/drivers/ksfilter/ks/device.c b/drivers/ksfilter/ks/device.c
index b2678c47a2b..5c3e528b3ca 100644
--- a/drivers/ksfilter/ks/device.c
+++ b/drivers/ksfilter/ks/device.c
@@ -295,13 +295,16 @@ IKsDevice_PnpStartDevice(
DPRINT("IKsDevice_PnpStartDevice DeviceHeader %p\n", DeviceHeader);
/* first forward irp to lower device object */
- Status = KspForwardIrpSynchronous(DeviceObject, Irp);
+ if (!IoForwardIrpSynchronously(DeviceHeader->KsDevice.NextDeviceObject, Irp))
+ {
+ Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
+ }
+ Status = Irp->IoStatus.Status;
/* check for success */
if (!NT_SUCCESS(Status))
{
DPRINT1("NextDevice object failed to start with %x\n", Status);
- Irp->IoStatus.Status = Status;
CompleteRequest(Irp, IO_NO_INCREMENT);
return Status;
}
@@ -459,13 +462,8 @@ IKsDevice_Pnp(
}
/* pass the irp down the driver stack */
- Status = KspForwardIrpSynchronous(DeviceObject, Irp);
-
- DPRINT("Next Device: Status %x\n", Status);
-
- Irp->IoStatus.Status = Status;
- CompleteRequest(Irp, IO_NO_INCREMENT);
- return Status;
+ IoSkipCurrentIrpStackLocation(Irp);
+ return IoCallDriver(DeviceHeader->KsDevice.NextDeviceObject, Irp);
}
case IRP_MN_REMOVE_DEVICE:
@@ -482,15 +480,9 @@ IKsDevice_Pnp(
}
/* pass the irp down the driver stack */
- Status = KspForwardIrpSynchronous(DeviceObject, Irp);
-
- DPRINT("Next Device: Status %x\n", Status);
-
+ IoSkipCurrentIrpStackLocation(Irp);
+ Status = IoCallDriver(DeviceHeader->KsDevice.NextDeviceObject, Irp);
/* FIXME delete device resources */
-
-
- Irp->IoStatus.Status = Status;
- CompleteRequest(Irp, IO_NO_INCREMENT);
return Status;
}
case IRP_MN_QUERY_INTERFACE:
@@ -518,23 +510,14 @@ IKsDevice_Pnp(
}
/* pass the irp down the driver stack */
- Status = KspForwardIrpSynchronous(DeviceObject, Irp);
-
- DPRINT1("IRP_MN_QUERY_INTERFACE Next Device: Status %x\n",
Status);
- Irp->IoStatus.Status = Status;
- CompleteRequest(Irp, IO_NO_INCREMENT);
- return Status;
+ IoSkipCurrentIrpStackLocation(Irp);
+ return IoCallDriver(DeviceHeader->KsDevice.NextDeviceObject, Irp);
}
case IRP_MN_QUERY_DEVICE_RELATIONS:
{
/* pass the irp down the driver stack */
- Status = KspForwardIrpSynchronous(DeviceObject, Irp);
-
- DPRINT("IRP_MN_QUERY_DEVICE_RELATIONS Next Device: Status %x\n",
Status);
-
- //Irp->IoStatus.Status = Status;
- CompleteRequest(Irp, IO_NO_INCREMENT);
- return Status;
+ IoSkipCurrentIrpStackLocation(Irp);
+ return IoCallDriver(DeviceHeader->KsDevice.NextDeviceObject, Irp);
}
case IRP_MN_FILTER_RESOURCE_REQUIREMENTS:
{
@@ -550,22 +533,14 @@ IKsDevice_Pnp(
case IRP_MN_QUERY_RESOURCE_REQUIREMENTS:
{
/* pass the irp down the driver stack */
- Status = KspForwardIrpSynchronous(DeviceObject, Irp);
-
- DPRINT("IRP_MN_QUERY_RESOURCE_REQUIREMENTS Next Device: Status
%x\n", Status);
-
- Irp->IoStatus.Status = Status;
- CompleteRequest(Irp, IO_NO_INCREMENT);
- return Status;
+ IoSkipCurrentIrpStackLocation(Irp);
+ return IoCallDriver(DeviceHeader->KsDevice.NextDeviceObject, Irp);
}
default:
- DPRINT1("unhandled function %u\n", IoStack->MinorFunction);
- /* pass the irp down the driver stack */
- Status = KspForwardIrpSynchronous(DeviceObject, Irp);
-
- Irp->IoStatus.Status = Status;
- CompleteRequest(Irp, IO_NO_INCREMENT);
- return Status;
+ DPRINT1("unhandled function %u\n", IoStack->MinorFunction);
+ /* pass the irp down the driver stack */
+ IoSkipCurrentIrpStackLocation(Irp);
+ return IoCallDriver(DeviceHeader->KsDevice.NextDeviceObject, Irp);
}
}
diff --git a/drivers/ksfilter/ks/ksfunc.h b/drivers/ksfilter/ks/ksfunc.h
index 8a930dde136..8c66635291e 100644
--- a/drivers/ksfilter/ks/ksfunc.h
+++ b/drivers/ksfilter/ks/ksfunc.h
@@ -74,11 +74,6 @@ KspRegisterDeviceInterfaces(
IN PUNICODE_STRING ReferenceString,
OUT PLIST_ENTRY SymbolicLinkList);
-NTSTATUS
-KspForwardIrpSynchronous(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp);
-
PVOID
AllocateItem(
IN POOL_TYPE PoolType,
diff --git a/drivers/ksfilter/ks/misc.c b/drivers/ksfilter/ks/misc.c
index f0ce95e909c..5174f850cf0 100644
--- a/drivers/ksfilter/ks/misc.c
+++ b/drivers/ksfilter/ks/misc.c
@@ -46,57 +46,6 @@ FreeItem(
ExFreePool(Item);
}
-NTSTATUS
-NTAPI
-KspForwardIrpSynchronousCompletion(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp,
- IN PVOID Context)
-{
- if (Irp->PendingReturned != FALSE)
- {
- KeSetEvent ((PKEVENT) Context, IO_NO_INCREMENT, FALSE);
- }
- return STATUS_MORE_PROCESSING_REQUIRED;
-}
-
-
-NTSTATUS
-KspForwardIrpSynchronous(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp)
-{
- KEVENT Event;
- NTSTATUS Status;
- PDEVICE_EXTENSION DeviceExtension;
- PKSIDEVICE_HEADER DeviceHeader;
-
- ASSERT_IRQL_EQUAL(PASSIVE_LEVEL);
-
- /* get device extension */
- DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
- /* get device header */
- DeviceHeader = DeviceExtension->DeviceHeader;
-
- /* initialize the notification event */
- KeInitializeEvent(&Event, NotificationEvent, FALSE);
-
- IoCopyCurrentIrpStackLocationToNext(Irp);
-
- IoSetCompletionRoutine(Irp, KspForwardIrpSynchronousCompletion, (PVOID)&Event,
TRUE, TRUE, TRUE);
-
- /* now call the driver */
- Status = IoCallDriver(DeviceHeader->KsDevice.NextDeviceObject, Irp);
- /* did the request complete yet */
- if (Status == STATUS_PENDING)
- {
- /* not yet, lets wait a bit */
- KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
- Status = Irp->IoStatus.Status;
- }
- return Status;
-}
-
NTSTATUS
KspCopyCreateRequest(
IN PIRP Irp,
diff --git a/drivers/parallel/parport/fdo.c b/drivers/parallel/parport/fdo.c
index deb9b63ba7e..bf5662c6a21 100644
--- a/drivers/parallel/parport/fdo.c
+++ b/drivers/parallel/parport/fdo.c
@@ -505,6 +505,7 @@ NTAPI
FdoPnp(IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
+ PFDO_DEVICE_EXTENSION FdoExtension;
ULONG MinorFunction;
PIO_STACK_LOCATION Stack;
ULONG_PTR Information = 0;
@@ -545,15 +546,21 @@ FdoPnp(IN PDEVICE_OBJECT DeviceObject,
case IRP_MN_START_DEVICE: /* 0x0 */
DPRINT("IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
-
ASSERT(((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Common.PnpState ==
dsStopped);
-
/* Call lower driver */
- Status = ForwardIrpAndWait(DeviceObject, Irp);
- if (NT_SUCCESS(Status))
+ FdoExtension = DeviceObject->DeviceExtension;
+ Status = STATUS_UNSUCCESSFUL;
+
+ ASSERT(FdoExtension->Common.PnpState == dsStopped);
+
+ if (IoForwardIrpSynchronously(FdoExtension->LowerDevice, Irp))
{
- Status = FdoStartDevice(DeviceObject,
-
Stack->Parameters.StartDevice.AllocatedResources,
-
Stack->Parameters.StartDevice.AllocatedResourcesTranslated);
+ Status = Irp->IoStatus.Status;
+ if (NT_SUCCESS(Status))
+ {
+ Status = FdoStartDevice(DeviceObject,
+ Stack->Parameters.StartDevice.AllocatedResources,
+ Stack->Parameters.StartDevice.AllocatedResourcesTranslated);
+ }
}
break;
diff --git a/drivers/parallel/parport/misc.c b/drivers/parallel/parport/misc.c
index f9a27bc7350..e9facba6749 100644
--- a/drivers/parallel/parport/misc.c
+++ b/drivers/parallel/parport/misc.c
@@ -8,52 +8,8 @@
#include "parport.h"
-static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion;
-
/* FUNCTIONS ****************************************************************/
-static
-NTSTATUS
-NTAPI
-ForwardIrpAndWaitCompletion(IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp,
- IN PVOID Context)
-{
- if (Irp->PendingReturned)
- KeSetEvent((PKEVENT)Context, IO_NO_INCREMENT, FALSE);
- return STATUS_MORE_PROCESSING_REQUIRED;
-}
-
-
-NTSTATUS
-ForwardIrpAndWait(IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp)
-{
- PDEVICE_OBJECT LowerDevice;
- KEVENT Event;
- NTSTATUS Status;
-
- LowerDevice =
((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
- ASSERT(LowerDevice);
-
- KeInitializeEvent(&Event, NotificationEvent, FALSE);
- IoCopyCurrentIrpStackLocationToNext(Irp);
-
- DPRINT("Calling lower device %p\n", LowerDevice);
- IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE,
TRUE);
-
- Status = IoCallDriver(LowerDevice, Irp);
- if (Status == STATUS_PENDING)
- {
- Status = KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
- if (NT_SUCCESS(Status))
- Status = Irp->IoStatus.Status;
- }
-
- return Status;
-}
-
-
NTSTATUS
NTAPI
ForwardIrpAndForget(IN PDEVICE_OBJECT DeviceObject,
diff --git a/drivers/parallel/parport/parport.h b/drivers/parallel/parport/parport.h
index 59a33a20f8c..9d4e30b90b7 100644
--- a/drivers/parallel/parport/parport.h
+++ b/drivers/parallel/parport/parport.h
@@ -109,10 +109,6 @@ FdoPower(IN PDEVICE_OBJECT DeviceObject,
/* misc.c */
-NTSTATUS
-ForwardIrpAndWait(IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp);
-
DRIVER_DISPATCH ForwardIrpAndForget;
PVOID
diff --git a/drivers/processor/processr/misc.c b/drivers/processor/processr/misc.c
index 39aa1d6604c..18478a54408 100644
--- a/drivers/processor/processr/misc.c
+++ b/drivers/processor/processr/misc.c
@@ -15,54 +15,6 @@
/* FUNCTIONS ******************************************************************/
-static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion;
-
-static
-NTSTATUS
-NTAPI
-ForwardIrpAndWaitCompletion(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp,
- IN PVOID Context)
-{
- if (Irp->PendingReturned)
- KeSetEvent((PKEVENT)Context, IO_NO_INCREMENT, FALSE);
-
- return STATUS_MORE_PROCESSING_REQUIRED;
-}
-
-
-NTSTATUS
-NTAPI
-ForwardIrpAndWait(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp)
-{
- PDEVICE_OBJECT LowerDevice;
- KEVENT Event;
- NTSTATUS Status;
-
- LowerDevice = ((PDEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
- ASSERT(LowerDevice);
-
- KeInitializeEvent(&Event, NotificationEvent, FALSE);
- IoCopyCurrentIrpStackLocationToNext(Irp);
-
- DPRINT("Calling lower device %p\n", LowerDevice);
- IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE,
TRUE);
-
- Status = IoCallDriver(LowerDevice, Irp);
- if (Status == STATUS_PENDING)
- {
- Status = KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
- if (NT_SUCCESS(Status))
- Status = Irp->IoStatus.Status;
- }
-
- return Status;
-}
-
-
NTSTATUS
NTAPI
ForwardIrpAndForget(
diff --git a/drivers/processor/processr/pnp.c b/drivers/processor/processr/pnp.c
index 08bcaf9b429..cb0fc452813 100644
--- a/drivers/processor/processr/pnp.c
+++ b/drivers/processor/processr/pnp.c
@@ -263,6 +263,7 @@ ProcessorPnp(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
+ PDEVICE_EXTENSION DeviceExtension;
PIO_STACK_LOCATION IrpSp;
ULONG_PTR Information = 0;
NTSTATUS Status = STATUS_NOT_SUPPORTED;
@@ -277,12 +278,18 @@ ProcessorPnp(
DPRINT(" IRP_MN_START_DEVICE received\n");
/* Call lower driver */
- Status = ForwardIrpAndWait(DeviceObject, Irp);
- if (NT_SUCCESS(Status))
+ DeviceExtension = DeviceObject->DeviceExtension;
+ Status = STATUS_UNSUCCESSFUL;
+
+ if (IoForwardIrpSynchronously(DeviceExtension->LowerDevice, Irp))
{
- Status = ProcessorStartDevice(DeviceObject,
-
IrpSp->Parameters.StartDevice.AllocatedResources,
-
IrpSp->Parameters.StartDevice.AllocatedResourcesTranslated);
+ Status = Irp->IoStatus.Status;
+ if (NT_SUCCESS(Status))
+ {
+ Status = ProcessorStartDevice(DeviceObject,
+ IrpSp->Parameters.StartDevice.AllocatedResources,
+ IrpSp->Parameters.StartDevice.AllocatedResourcesTranslated);
+ }
}
break;
diff --git a/drivers/processor/processr/processr.h
b/drivers/processor/processr/processr.h
index 3e513bbb3ef..e394acdd421 100644
--- a/drivers/processor/processr/processr.h
+++ b/drivers/processor/processr/processr.h
@@ -21,12 +21,6 @@ typedef struct _DEVICE_EXTENSION
/* misc.c */
-NTSTATUS
-NTAPI
-ForwardIrpAndWait(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp);
-
NTSTATUS
NTAPI
ForwardIrpAndForget(
diff --git a/drivers/serial/serenum/fdo.c b/drivers/serial/serenum/fdo.c
index d07682bdeba..fd6ff9c2423 100644
--- a/drivers/serial/serenum/fdo.c
+++ b/drivers/serial/serenum/fdo.c
@@ -153,6 +153,7 @@ SerenumFdoPnp(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
+ PFDO_DEVICE_EXTENSION FdoExtension;
ULONG MinorFunction;
PIO_STACK_LOCATION Stack;
ULONG_PTR Information = 0;
@@ -181,9 +182,18 @@ SerenumFdoPnp(
{
TRACE_(SERENUM, "IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
/* Call lower driver */
- Status = ForwardIrpAndWait(DeviceObject, Irp);
- if (NT_SUCCESS(Status))
- Status = SerenumFdoStartDevice(DeviceObject, Irp);
+ FdoExtension = DeviceObject->DeviceExtension;
+ Status = STATUS_UNSUCCESSFUL;
+
+ if (IoForwardIrpSynchronously(FdoExtension->LowerDevice, Irp))
+ {
+ Status = Irp->IoStatus.Status;
+ if (NT_SUCCESS(Status))
+ {
+ Status = SerenumFdoStartDevice(DeviceObject, Irp);
+ }
+ }
+
break;
}
case IRP_MN_QUERY_DEVICE_RELATIONS: /* 0x7 */
diff --git a/drivers/serial/serenum/misc.c b/drivers/serial/serenum/misc.c
index 8541da196ee..e5c58d3f278 100644
--- a/drivers/serial/serenum/misc.c
+++ b/drivers/serial/serenum/misc.c
@@ -11,8 +11,6 @@
#include <debug.h>
-static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion;
-
/* I really want PCSZ strings as last arguments because
* PnP ids are ANSI-encoded in PnP device string
* identification */
@@ -88,48 +86,6 @@ SerenumInitMultiSzString(
return Status;
}
-static NTSTATUS NTAPI
-ForwardIrpAndWaitCompletion(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp,
- IN PVOID Context)
-{
- if (Irp->PendingReturned)
- KeSetEvent((PKEVENT)Context, IO_NO_INCREMENT, FALSE);
- return STATUS_MORE_PROCESSING_REQUIRED;
-}
-
-NTSTATUS
-ForwardIrpAndWait(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp)
-{
- PDEVICE_OBJECT LowerDevice;
- KEVENT Event;
- NTSTATUS Status;
-
- ASSERT(((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO);
- LowerDevice =
((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
-
- ASSERT(LowerDevice);
-
- KeInitializeEvent(&Event, NotificationEvent, FALSE);
- IoCopyCurrentIrpStackLocationToNext(Irp);
-
- TRACE_(SERENUM, "Calling lower device %p\n", LowerDevice);
- IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE, TRUE);
-
- Status = IoCallDriver(LowerDevice, Irp);
- if (Status == STATUS_PENDING)
- {
- Status = KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
- if (NT_SUCCESS(Status))
- Status = Irp->IoStatus.Status;
- }
-
- return Status;
-}
-
NTSTATUS NTAPI
ForwardIrpToLowerDeviceAndForget(
IN PDEVICE_OBJECT DeviceObject,
diff --git a/drivers/serial/serial/misc.c b/drivers/serial/serial/misc.c
index 8a87d7ceff6..3771bed79c4 100644
--- a/drivers/serial/serial/misc.c
+++ b/drivers/serial/serial/misc.c
@@ -12,46 +12,6 @@
#include <debug.h>
-static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion;
-
-static NTSTATUS NTAPI
-ForwardIrpAndWaitCompletion(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp,
- IN PVOID Context)
-{
- if (Irp->PendingReturned)
- KeSetEvent((PKEVENT)Context, IO_NO_INCREMENT, FALSE);
- return STATUS_MORE_PROCESSING_REQUIRED;
-}
-
-NTSTATUS
-ForwardIrpAndWait(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp)
-{
- PDEVICE_OBJECT LowerDevice =
((PSERIAL_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
- KEVENT Event;
- NTSTATUS Status;
-
- ASSERT(LowerDevice);
-
- KeInitializeEvent(&Event, NotificationEvent, FALSE);
- IoCopyCurrentIrpStackLocationToNext(Irp);
-
- TRACE_(SERIAL, "Calling lower device %p\n", LowerDevice);
- IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE, TRUE);
-
- Status = IoCallDriver(LowerDevice, Irp);
- if (Status == STATUS_PENDING)
- {
- Status = KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
- if (NT_SUCCESS(Status))
- Status = Irp->IoStatus.Status;
- }
-
- return Status;
-}
NTSTATUS NTAPI
ForwardIrpAndForget(
diff --git a/drivers/serial/serial/pnp.c b/drivers/serial/serial/pnp.c
index 15c0ff4a2de..94dcc1b8931 100644
--- a/drivers/serial/serial/pnp.c
+++ b/drivers/serial/serial/pnp.c
@@ -328,6 +328,7 @@ SerialPnp(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
+ PSERIAL_DEVICE_EXTENSION DeviceExtension;
ULONG MinorFunction;
PIO_STACK_LOCATION Stack;
ULONG_PTR Information = 0;
@@ -367,15 +368,24 @@ SerialPnp(
{
TRACE_(SERIAL, "IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
- ASSERT(((PSERIAL_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->PnpState ==
dsStopped);
-
/* Call lower driver */
- Status = ForwardIrpAndWait(DeviceObject, Irp);
- if (NT_SUCCESS(Status))
- Status = SerialPnpStartDevice(
- DeviceObject,
- Stack->Parameters.StartDevice.AllocatedResources,
- Stack->Parameters.StartDevice.AllocatedResourcesTranslated);
+ DeviceExtension = DeviceObject->DeviceExtension;
+ Status = STATUS_UNSUCCESSFUL;
+
+ ASSERT(DeviceExtension->PnpState == dsStopped);
+
+ if (IoForwardIrpSynchronously(DeviceExtension->LowerDevice, Irp))
+ {
+ Status = Irp->IoStatus.Status;
+ if (NT_SUCCESS(Status))
+ {
+ Status = SerialPnpStartDevice(
+ DeviceObject,
+ Stack->Parameters.StartDevice.AllocatedResources,
+ Stack->Parameters.StartDevice.AllocatedResourcesTranslated);
+ }
+ }
+
break;
}
case IRP_MN_QUERY_DEVICE_RELATIONS: /* (optional) 0x7 */
diff --git a/drivers/serial/serial/serial.h b/drivers/serial/serial/serial.h
index ad7011dc003..1d78d3a6d9a 100644
--- a/drivers/serial/serial/serial.h
+++ b/drivers/serial/serial/serial.h
@@ -242,11 +242,6 @@ SerialDetectUartType(
/************************************ misc.c */
-NTSTATUS
-ForwardIrpAndWait(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp);
-
DRIVER_DISPATCH ForwardIrpAndForget;
VOID NTAPI
diff --git a/drivers/storage/floppy/fdc/fdo.c b/drivers/storage/floppy/fdc/fdo.c
index d9a759c5d26..f00c58c08d9 100644
--- a/drivers/storage/floppy/fdc/fdo.c
+++ b/drivers/storage/floppy/fdc/fdo.c
@@ -16,51 +16,6 @@
/* FUNCTIONS ******************************************************************/
-static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion;
-
-static
-NTSTATUS
-NTAPI
-ForwardIrpAndWaitCompletion(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp,
- IN PVOID Context)
-{
- if (Irp->PendingReturned)
- KeSetEvent((PKEVENT)Context, IO_NO_INCREMENT, FALSE);
- return STATUS_MORE_PROCESSING_REQUIRED;
-}
-
-
-NTSTATUS
-ForwardIrpAndWait(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp)
-{
- PDEVICE_OBJECT LowerDevice =
((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
- KEVENT Event;
- NTSTATUS Status;
-
- ASSERT(LowerDevice);
-
- KeInitializeEvent(&Event, NotificationEvent, FALSE);
- IoCopyCurrentIrpStackLocationToNext(Irp);
-
- DPRINT("Calling lower device %p\n", LowerDevice);
- IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE,
TRUE);
-
- Status = IoCallDriver(LowerDevice, Irp);
- if (Status == STATUS_PENDING)
- {
- Status = KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
- if (NT_SUCCESS(Status))
- Status = Irp->IoStatus.Status;
- }
-
- return Status;
-}
-
-
NTSTATUS
NTAPI
ForwardIrpAndForget(
@@ -492,6 +447,7 @@ FdcFdoPnp(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
+ PFDO_DEVICE_EXTENSION FdoExtension;
PIO_STACK_LOCATION IrpSp;
PDEVICE_RELATIONS DeviceRelations = NULL;
ULONG_PTR Information = 0;
@@ -505,14 +461,22 @@ FdcFdoPnp(
{
case IRP_MN_START_DEVICE:
DPRINT(" IRP_MN_START_DEVICE received\n");
+
/* Call lower driver */
- Status = ForwardIrpAndWait(DeviceObject, Irp);
- if (NT_SUCCESS(Status))
+ Status = STATUS_UNSUCCESSFUL;
+ FdoExtension = DeviceObject->DeviceExtension;
+
+ if (IoForwardIrpSynchronously(FdoExtension->LowerDevice, Irp))
{
- Status = FdcFdoStartDevice(DeviceObject,
-
IrpSp->Parameters.StartDevice.AllocatedResources,
-
IrpSp->Parameters.StartDevice.AllocatedResourcesTranslated);
+ Status = Irp->IoStatus.Status;
+ if (NT_SUCCESS(Status))
+ {
+ Status = FdcFdoStartDevice(DeviceObject,
+ IrpSp->Parameters.StartDevice.AllocatedResources,
+ IrpSp->Parameters.StartDevice.AllocatedResourcesTranslated);
+ }
}
+
break;
case IRP_MN_QUERY_REMOVE_DEVICE:
diff --git a/drivers/storage/ide/pciidex/fdo.c b/drivers/storage/ide/pciidex/fdo.c
index 12387344b53..b4b7a244d3d 100644
--- a/drivers/storage/ide/pciidex/fdo.c
+++ b/drivers/storage/ide/pciidex/fdo.c
@@ -403,6 +403,7 @@ PciIdeXFdoPnpDispatch(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
+ PFDO_DEVICE_EXTENSION FdoExtension;
ULONG MinorFunction;
PIO_STACK_LOCATION Stack;
ULONG_PTR Information = Irp->IoStatus.Information;
@@ -416,10 +417,19 @@ PciIdeXFdoPnpDispatch(
case IRP_MN_START_DEVICE: /* 0x00 */
{
DPRINT("IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
+
/* Call lower driver */
- Status = ForwardIrpAndWait(DeviceObject, Irp);
- if (NT_SUCCESS(Status))
- Status = PciIdeXFdoStartDevice(DeviceObject, Irp);
+ FdoExtension = DeviceObject->DeviceExtension;
+ Status = STATUS_UNSUCCESSFUL;
+
+ if (IoForwardIrpSynchronously(FdoExtension->LowerDevice, Irp))
+ {
+ Status = Irp->IoStatus.Status;
+ if (NT_SUCCESS(Status))
+ {
+ Status = PciIdeXFdoStartDevice(DeviceObject, Irp);
+ }
+ }
break;
}
case IRP_MN_QUERY_REMOVE_DEVICE: /* 0x01 */
diff --git a/drivers/storage/ide/pciidex/misc.c b/drivers/storage/ide/pciidex/misc.c
index 9126293ca59..46ebf5d3847 100644
--- a/drivers/storage/ide/pciidex/misc.c
+++ b/drivers/storage/ide/pciidex/misc.c
@@ -11,46 +11,6 @@
#define NDEBUG
#include <debug.h>
-NTSTATUS NTAPI
-PciIdeXGenericCompletion(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp,
- IN PVOID Context)
-{
- if (Irp->PendingReturned)
- KeSetEvent((PKEVENT)Context, IO_NO_INCREMENT, FALSE);
- return STATUS_MORE_PROCESSING_REQUIRED;
-}
-
-NTSTATUS
-ForwardIrpAndWait(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp)
-{
- PDEVICE_OBJECT LowerDevice;
- KEVENT Event;
- NTSTATUS Status;
-
- ASSERT(((PCOMMON_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->IsFDO);
- LowerDevice =
((PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
- ASSERT(LowerDevice);
-
- KeInitializeEvent(&Event, NotificationEvent, FALSE);
- IoCopyCurrentIrpStackLocationToNext(Irp);
-
- DPRINT("Calling lower device %p [%wZ]\n", LowerDevice,
&LowerDevice->DriverObject->DriverName);
- IoSetCompletionRoutine(Irp, PciIdeXGenericCompletion, &Event, TRUE, TRUE, TRUE);
-
- Status = IoCallDriver(LowerDevice, Irp);
- if (Status == STATUS_PENDING)
- {
- Status = KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
- if (NT_SUCCESS(Status))
- Status = Irp->IoStatus.Status;
- }
-
- return Status;
-}
NTSTATUS NTAPI
ForwardIrpAndForget(
diff --git a/drivers/storage/ide/pciidex/pciidex.h
b/drivers/storage/ide/pciidex/pciidex.h
index 34c360c22f4..4dde936a44f 100644
--- a/drivers/storage/ide/pciidex/pciidex.h
+++ b/drivers/storage/ide/pciidex/pciidex.h
@@ -53,18 +53,6 @@ PciIdeXFdoPnpDispatch(
/* misc.c */
-IO_COMPLETION_ROUTINE PciIdeXGenericCompletion;
-NTSTATUS NTAPI
-PciIdeXGenericCompletion(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp,
- IN PVOID Context);
-
-NTSTATUS
-ForwardIrpAndWait(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp);
-
NTSTATUS NTAPI
ForwardIrpAndForget(
IN PDEVICE_OBJECT DeviceObject,
diff --git a/drivers/storage/port/storport/fdo.c b/drivers/storage/port/storport/fdo.c
index bf1ff419206..48cee37fce1 100644
--- a/drivers/storage/port/storport/fdo.c
+++ b/drivers/storage/port/storport/fdo.c
@@ -191,10 +191,18 @@ PortFdoStartDevice(
/* Start the lower device if the FDO is in 'stopped' state */
if (DeviceExtension->PnpState == dsStopped)
{
- Status = ForwardIrpAndWait(DeviceExtension->LowerDevice, Irp);
+ if (IoForwardIrpSynchronously(DeviceExtension->LowerDevice, Irp))
+ {
+ Status = Irp->IoStatus.Status;
+ }
+ else
+ {
+ Status = STATUS_UNSUCCESSFUL;
+ }
+
if (!NT_SUCCESS(Status))
{
- DPRINT1("ForwardIrpAndWait() failed (Status 0x%08lx)\n", Status);
+ DPRINT1("Lower device failed the IRP (Status 0x%08lx)\n", Status);
return Status;
}
}
diff --git a/drivers/storage/port/storport/misc.c b/drivers/storage/port/storport/misc.c
index f524ef6f62d..58e671d45c9 100644
--- a/drivers/storage/port/storport/misc.c
+++ b/drivers/storage/port/storport/misc.c
@@ -15,47 +15,6 @@
/* FUNCTIONS ******************************************************************/
-static
-NTSTATUS
-NTAPI
-ForwardIrpAndWaitCompletion(
- _In_ PDEVICE_OBJECT DeviceObject,
- _In_ PIRP Irp,
- _In_ PVOID Context)
-{
- if (Irp->PendingReturned)
- KeSetEvent((PKEVENT)Context, IO_NO_INCREMENT, FALSE);
- return STATUS_MORE_PROCESSING_REQUIRED;
-}
-
-
-NTSTATUS
-ForwardIrpAndWait(
- _In_ PDEVICE_OBJECT LowerDevice,
- _In_ PIRP Irp)
-{
- KEVENT Event;
- NTSTATUS Status;
-
- ASSERT(LowerDevice);
-
- KeInitializeEvent(&Event, NotificationEvent, FALSE);
- IoCopyCurrentIrpStackLocationToNext(Irp);
-
- IoSetCompletionRoutine(Irp, ForwardIrpAndWaitCompletion, &Event, TRUE, TRUE,
TRUE);
-
- Status = IoCallDriver(LowerDevice, Irp);
- if (Status == STATUS_PENDING)
- {
- Status = KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
- if (NT_SUCCESS(Status))
- Status = Irp->IoStatus.Status;
- }
-
- return Status;
-}
-
-
NTSTATUS
NTAPI
ForwardIrpAndForget(
diff --git a/drivers/storage/port/storport/precomp.h
b/drivers/storage/port/storport/precomp.h
index 6f3436aa237..698da94f013 100644
--- a/drivers/storage/port/storport/precomp.h
+++ b/drivers/storage/port/storport/precomp.h
@@ -178,11 +178,6 @@ MiniportStartIo(
/* misc.c */
-NTSTATUS
-ForwardIrpAndWait(
- _In_ PDEVICE_OBJECT LowerDevice,
- _In_ PIRP Irp);
-
NTSTATUS
NTAPI
ForwardIrpAndForget(
diff --git a/drivers/usb/usbccgp/fdo.c b/drivers/usb/usbccgp/fdo.c
index abcaeb017f3..833893b3509 100644
--- a/drivers/usb/usbccgp/fdo.c
+++ b/drivers/usb/usbccgp/fdo.c
@@ -253,7 +253,14 @@ FDO_StartDevice(
ASSERT(FDODeviceExtension->Common.IsFDO);
/* First start lower device */
- Status = USBCCGP_SyncForwardIrp(FDODeviceExtension->NextDeviceObject, Irp);
+ if (IoForwardIrpSynchronously(FDODeviceExtension->NextDeviceObject, Irp))
+ {
+ Status = Irp->IoStatus.Status;
+ }
+ else
+ {
+ Status = STATUS_UNSUCCESSFUL;
+ }
if (!NT_SUCCESS(Status))
{
@@ -435,11 +442,15 @@ FDO_HandlePnp(
RtlCopyMemory(IoStack->Parameters.DeviceCapabilities.Capabilities,
&FDODeviceExtension->Capabilities,
sizeof(DEVICE_CAPABILITIES));
- Status = USBCCGP_SyncForwardIrp(FDODeviceExtension->NextDeviceObject,
Irp);
- if (NT_SUCCESS(Status))
+ Status = STATUS_UNSUCCESSFUL;
+
+ if (IoForwardIrpSynchronously(FDODeviceExtension->NextDeviceObject, Irp))
{
- /* Surprise removal ok */
-
IoStack->Parameters.DeviceCapabilities.Capabilities->SurpriseRemovalOK = TRUE;
+ Status = Irp->IoStatus.Status;
+ if (NT_SUCCESS(Status))
+ {
+
IoStack->Parameters.DeviceCapabilities.Capabilities->SurpriseRemovalOK = TRUE;
+ }
}
break;
}
@@ -527,7 +538,7 @@ FDO_HandleResetCyclePort(
KeReleaseSpinLock(&FDODeviceExtension->Lock, OldLevel);
/* Forward request synchronized */
- USBCCGP_SyncForwardIrp(FDODeviceExtension->NextDeviceObject, Irp);
+ NT_VERIFY(IoForwardIrpSynchronously(FDODeviceExtension->NextDeviceObject,
Irp));
/* Reacquire lock */
KeAcquireSpinLock(&FDODeviceExtension->Lock, &OldLevel);
diff --git a/drivers/usb/usbccgp/misc.c b/drivers/usb/usbccgp/misc.c
index e8c3e82f8e4..5edd293838f 100644
--- a/drivers/usb/usbccgp/misc.c
+++ b/drivers/usb/usbccgp/misc.c
@@ -31,46 +31,6 @@ USBSTOR_SyncForwardIrpCompletionRoutine(
return STATUS_MORE_PROCESSING_REQUIRED;
}
-NTSTATUS
-NTAPI
-USBCCGP_SyncForwardIrp(
- PDEVICE_OBJECT DeviceObject,
- PIRP Irp)
-{
- KEVENT Event;
- NTSTATUS Status;
-
- /* Initialize event */
- KeInitializeEvent(&Event, NotificationEvent, FALSE);
-
- /* Copy irp stack location */
- IoCopyCurrentIrpStackLocationToNext(Irp);
-
- /* Set completion routine */
- IoSetCompletionRoutine(Irp,
- USBSTOR_SyncForwardIrpCompletionRoutine,
- &Event,
- TRUE,
- TRUE,
- TRUE);
-
- /* Call driver */
- Status = IoCallDriver(DeviceObject, Irp);
-
- /* Check if pending */
- if (Status == STATUS_PENDING)
- {
- /* Wait for the request to finish */
- KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
-
- /* Copy status code */
- Status = Irp->IoStatus.Status;
- }
-
- /* Done */
- return Status;
-}
-
NTSTATUS
USBCCGP_SyncUrbRequest(
IN PDEVICE_OBJECT DeviceObject,
diff --git a/drivers/usb/usbccgp/pdo.c b/drivers/usb/usbccgp/pdo.c
index 1ea62bdf0e2..da73ed12ba6 100644
--- a/drivers/usb/usbccgp/pdo.c
+++ b/drivers/usb/usbccgp/pdo.c
@@ -231,7 +231,15 @@ USBCCGP_PdoHandleQueryId(
//
// handle query device id
//
- Status = USBCCGP_SyncForwardIrp(PDODeviceExtension->NextDeviceObject, Irp);
+ if (IoForwardIrpSynchronously(PDODeviceExtension->NextDeviceObject, Irp))
+ {
+ Status = Irp->IoStatus.Status;
+ }
+ else
+ {
+ Status = STATUS_UNSUCCESSFUL;
+ }
+
if (NT_SUCCESS(Status))
{
//
diff --git a/drivers/usb/usbccgp/usbccgp.h b/drivers/usb/usbccgp/usbccgp.h
index 7b50992822b..04ce3493336 100644
--- a/drivers/usb/usbccgp/usbccgp.h
+++ b/drivers/usb/usbccgp/usbccgp.h
@@ -98,12 +98,6 @@ AllocateInterfaceDescriptorsArray(
/* misc.c */
-NTSTATUS
-NTAPI
-USBCCGP_SyncForwardIrp(
- PDEVICE_OBJECT DeviceObject,
- PIRP Irp);
-
NTSTATUS
USBCCGP_SyncUrbRequest(
IN PDEVICE_OBJECT DeviceObject,
diff --git a/drivers/usb/usbstor/fdo.c b/drivers/usb/usbstor/fdo.c
index 6b8aa4c3e09..40c4626c8d6 100644
--- a/drivers/usb/usbstor/fdo.c
+++ b/drivers/usb/usbstor/fdo.c
@@ -160,7 +160,12 @@ USBSTOR_FdoHandleStartDevice(
PIO_WORKITEM WorkItem;
// forward irp to lower device
- Status = USBSTOR_SyncForwardIrp(DeviceExtension->LowerDeviceObject, Irp);
+ if (!IoForwardIrpSynchronously(DeviceExtension->LowerDeviceObject, Irp))
+ {
+ return STATUS_UNSUCCESSFUL;
+ }
+
+ Status = Irp->IoStatus.Status;
if (!NT_SUCCESS(Status))
{
DPRINT1("USBSTOR_FdoHandleStartDevice Lower device failed to start
%x\n", Status);
diff --git a/drivers/usb/usbstor/misc.c b/drivers/usb/usbstor/misc.c
index 040ca568d94..71af4c1fd61 100644
--- a/drivers/usb/usbstor/misc.c
+++ b/drivers/usb/usbstor/misc.c
@@ -29,29 +29,6 @@ USBSTOR_SyncForwardIrpCompletionRoutine(
return STATUS_MORE_PROCESSING_REQUIRED;
}
-NTSTATUS
-NTAPI
-USBSTOR_SyncForwardIrp(PDEVICE_OBJECT DeviceObject, PIRP Irp)
-{
- KEVENT Event;
- NTSTATUS Status;
-
- KeInitializeEvent(&Event, NotificationEvent, FALSE);
- IoCopyCurrentIrpStackLocationToNext(Irp);
- IoSetCompletionRoutine(Irp, USBSTOR_SyncForwardIrpCompletionRoutine, &Event,
TRUE, TRUE, TRUE);
-
- Status = IoCallDriver(DeviceObject, Irp);
-
- if (Status == STATUS_PENDING)
- {
- // wait for the request to finish
- KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
- Status = Irp->IoStatus.Status;
- }
-
- return Status;
-}
-
NTSTATUS
NTAPI
USBSTOR_GetBusInterface(
diff --git a/drivers/usb/usbstor/pdo.c b/drivers/usb/usbstor/pdo.c
index 8510a7941e6..28039993340 100644
--- a/drivers/usb/usbstor/pdo.c
+++ b/drivers/usb/usbstor/pdo.c
@@ -589,16 +589,21 @@ USBSTOR_PdoHandlePnp(
case IRP_MN_QUERY_CAPABILITIES:
{
// just forward irp to lower device
- Status = USBSTOR_SyncForwardIrp(DeviceExtension->LowerDeviceObject, Irp);
- ASSERT(Status == STATUS_SUCCESS);
+ Status = STATUS_UNSUCCESSFUL;
- if (NT_SUCCESS(Status))
- {
- // check if no unique id
- Caps =
(PDEVICE_CAPABILITIES)IoStack->Parameters.DeviceCapabilities.Capabilities;
- Caps->UniqueID = FALSE; // no unique id is supported
- Caps->Removable = TRUE; //FIXME
- }
+ if (IoForwardIrpSynchronously(DeviceExtension->LowerDeviceObject, Irp))
+ {
+ Status = Irp->IoStatus.Status;
+ ASSERT(Status == STATUS_SUCCESS);
+
+ if (NT_SUCCESS(Status))
+ {
+ // check if no unique id
+ Caps =
(PDEVICE_CAPABILITIES)IoStack->Parameters.DeviceCapabilities.Capabilities;
+ Caps->UniqueID = FALSE; // no unique id is supported
+ Caps->Removable = TRUE; //FIXME
+ }
+ }
break;
}
case IRP_MN_QUERY_REMOVE_DEVICE:
diff --git a/drivers/usb/usbstor/usbstor.h b/drivers/usb/usbstor/usbstor.h
index 318010f791e..8a65e2bd521 100644
--- a/drivers/usb/usbstor/usbstor.h
+++ b/drivers/usb/usbstor/usbstor.h
@@ -215,11 +215,6 @@ USBSTOR_CreatePDO(
//
// misc.c routines
//
-NTSTATUS
-NTAPI
-USBSTOR_SyncForwardIrp(
- IN PDEVICE_OBJECT DeviceObject,
- IN OUT PIRP Irp);
NTSTATUS
NTAPI
@@ -246,13 +241,6 @@ USBSTOR_GetMaxLUN(
IN PDEVICE_OBJECT DeviceObject,
IN PFDO_DEVICE_EXTENSION DeviceExtension);
-NTSTATUS
-NTAPI
-USBSTOR_SyncForwardIrpCompletionRoutine(
- PDEVICE_OBJECT DeviceObject,
- PIRP Irp,
- PVOID Context);
-
NTSTATUS
USBSTOR_ResetDevice(
IN PDEVICE_OBJECT DeviceObject,
diff --git a/drivers/wdm/audio/legacy/stream/helper.c
b/drivers/wdm/audio/legacy/stream/helper.c
deleted file mode 100644
index 6d2a844dc7f..00000000000
--- a/drivers/wdm/audio/legacy/stream/helper.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS Kernel Streaming
- * FILE: drivers/wdm/audio/legacy/stream/helper.c
- * PURPOSE: irp helper routines
- * PROGRAMMER: Johannes Anderwald
- */
-
-
-#include "stream.h"
-
-NTSTATUS
-NTAPI
-CompletionRoutine(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp,
- IN PVOID Context)
-{
- if (Irp->PendingReturned != FALSE)
- {
- KeSetEvent ((PKEVENT) Context, IO_NO_INCREMENT, FALSE);
- }
- return STATUS_MORE_PROCESSING_REQUIRED;
-}
-
-
-NTSTATUS
-NTAPI
-ForwardIrpSynchronous(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp)
-{
- KEVENT Event;
- PSTREAM_DEVICE_EXTENSION DeviceExt;
- NTSTATUS Status;
-
- DeviceExt = (PSTREAM_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
-
- /* initialize the notification event */
- KeInitializeEvent(&Event, NotificationEvent, FALSE);
-
- IoCopyCurrentIrpStackLocationToNext(Irp);
-
- IoSetCompletionRoutine(Irp, CompletionRoutine, (PVOID)&Event, TRUE, TRUE, TRUE);
-
- /* now call the driver */
- Status = IoCallDriver(DeviceExt->LowerDeviceObject, Irp);
- /* did the request complete yet */
- if (Status == STATUS_PENDING)
- {
- /* not yet, lets wait a bit */
- KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
- Status = Irp->IoStatus.Status;
- }
- return Status;
-}
diff --git a/drivers/wdm/audio/legacy/stream/pnp.c
b/drivers/wdm/audio/legacy/stream/pnp.c
index b8814cdb1fd..8df55e8bd66 100644
--- a/drivers/wdm/audio/legacy/stream/pnp.c
+++ b/drivers/wdm/audio/legacy/stream/pnp.c
@@ -353,7 +353,15 @@ StreamClassStartDevice(
/* First forward the request to lower attached device object */
- Status = ForwardIrpSynchronous(DeviceObject, Irp);
+ if (IoForwardIrpSynchronously(DeviceExtension->LowerDeviceObject, Irp))
+ {
+ Status = Irp->IoStatus.Status;
+ }
+ else
+ {
+ Status = STATUS_UNSUCCESSFUL;
+ }
+
if (!NT_SUCCESS(Status))
{
/* Failed to start lower devices */
diff --git a/drivers/wdm/audio/legacy/stream/stream.h
b/drivers/wdm/audio/legacy/stream/stream.h
index 6208d3a79eb..5994d91be56 100644
--- a/drivers/wdm/audio/legacy/stream/stream.h
+++ b/drivers/wdm/audio/legacy/stream/stream.h
@@ -102,13 +102,6 @@ StreamClassAddDevice(
IN PDRIVER_OBJECT DriverObject,
IN PDEVICE_OBJECT PhysicalDeviceObject);
-
-NTSTATUS
-NTAPI
-ForwardIrpSynchronous(
- IN PDEVICE_OBJECT DeviceObject,
- IN PIRP Irp);
-
BOOLEAN
NTAPI
StreamClassSynchronize(