From 007814383b99c5ca56f0ff6d69438ffa0aa1319e Mon Sep 17 00:00:00 2001 From: Vizzini Date: Sat, 13 Mar 2004 07:04:54 +0000 Subject: [PATCH] fixed two race conditions with motor power-off; now handles disk change detection and no-disk-in-drive correctly svn path=/trunk/; revision=8679 --- reactos/drivers/storage/floppy/floppy.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/reactos/drivers/storage/floppy/floppy.c b/reactos/drivers/storage/floppy/floppy.c index 5299957861d..541e026b3f0 100644 --- a/reactos/drivers/storage/floppy/floppy.c +++ b/reactos/drivers/storage/floppy/floppy.c @@ -115,14 +115,16 @@ VOID NTAPI StartMotor(PDRIVE_INFO DriveInfo) KdPrint(("floppy: StartMotor called\n")); - if(DriveInfo->ControllerInfo->StopDpcQueued && - !KeCancelTimer(&DriveInfo->ControllerInfo->MotorTimer)) + if(DriveInfo->ControllerInfo->StopDpcQueued && !KeCancelTimer(&DriveInfo->ControllerInfo->MotorTimer)) { /* Motor turner-offer is already running; wait for it to finish */ + KdPrint(("floppy: StartMotor: motor turner-offer is already running; waiting for it\n")); KeWaitForSingleObject(&DriveInfo->ControllerInfo->MotorStoppedEvent, Executive, KernelMode, FALSE, NULL); - DriveInfo->ControllerInfo->StopDpcQueued = FALSE; + KdPrint(("floppy: StartMotor: wait satisfied\n")); } + DriveInfo->ControllerInfo->StopDpcQueued = FALSE; + if(HwTurnOnMotor(DriveInfo) != STATUS_SUCCESS) KdPrint(("floppy: StartMotor(): warning: HwTurnOnMotor failed\n")); } @@ -768,7 +770,7 @@ static NTSTATUS NTAPI InitController(PCONTROLLER_INFO ControllerInfo) /* Init the stop stuff */ KeInitializeDpc(&ControllerInfo->MotorStopDpc, MotorStopDpcFunc, ControllerInfo); KeInitializeTimer(&ControllerInfo->MotorTimer); - KeInitializeEvent(&ControllerInfo->MotorStoppedEvent, SynchronizationEvent, FALSE); + KeInitializeEvent(&ControllerInfo->MotorStoppedEvent, NotificationEvent, FALSE); ControllerInfo->StopDpcQueued = FALSE; /*