mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 13:35:47 +00:00
[DRIVERS] Use IoForwardIrpSynchronously in drivers
Instead of having an own routine in each driver IoForwardIrpSynchronously can be used.
This commit is contained in:
parent
8e8f61989a
commit
7ed1883c8e
45 changed files with 238 additions and 866 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -109,10 +109,6 @@ FdoPower(IN PDEVICE_OBJECT DeviceObject,
|
|||
|
||||
/* misc.c */
|
||||
|
||||
NTSTATUS
|
||||
ForwardIrpAndWait(IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
|
||||
DRIVER_DISPATCH ForwardIrpAndForget;
|
||||
|
||||
PVOID
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue