Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
1.9 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1998 - 1999
  3. Module Name:
  4. parport.sys
  5. File Name:
  6. cleanup.c
  7. Abstract:
  8. This file contains the dispatch routine for handling IRP_MJ_CLEANUP.
  9. Exports:
  10. - PptDispatchCleanup() - The dispatch routine for cleanup.
  11. --*/
  12. #include "pch.h"
  13. NTSTATUS
  14. PptFdoCleanup(
  15. IN PDEVICE_OBJECT DeviceObject,
  16. IN PIRP Irp
  17. )
  18. /*++dvdf3
  19. Routine Description:
  20. This is the dispatch routine for handling IRP_MJ_CLEANUP IRPs.
  21. This routine cancels all of the IRPs currently queued on
  22. for the specified device.
  23. Arguments:
  24. DeviceObject - Supplies the device object.
  25. Irp - Supplies the cleanup IRP.
  26. Return Value:
  27. STATUS_SUCCESS - Success.
  28. --*/
  29. {
  30. PFDO_EXTENSION fdx = DeviceObject->DeviceExtension;
  31. PIRP nextIrp;
  32. KIRQL cancelIrql;
  33. DD((PCE)fdx,DDT,"PptFdoCleanup\n");
  34. //
  35. // Verify that our device has not been SUPRISE_REMOVED. If we
  36. // have been SUPRISE_REMOVED then we have already cleaned up
  37. // as part of the handling of the surprise removal.
  38. //
  39. if( fdx->PnpState & PPT_DEVICE_SURPRISE_REMOVED ) {
  40. goto targetExit;
  41. }
  42. IoAcquireCancelSpinLock( &cancelIrql );
  43. while( !IsListEmpty( &fdx->WorkQueue ) ) {
  44. nextIrp = CONTAINING_RECORD(fdx->WorkQueue.Blink, IRP, Tail.Overlay.ListEntry);
  45. nextIrp->Cancel = TRUE;
  46. nextIrp->CancelIrql = cancelIrql;
  47. nextIrp->CancelRoutine = NULL;
  48. PptCancelRoutine(DeviceObject, nextIrp);
  49. // need to reacquire because PptCancelRoutine() releases the SpinLock
  50. IoAcquireCancelSpinLock(&cancelIrql);
  51. }
  52. IoReleaseCancelSpinLock( cancelIrql );
  53. targetExit:
  54. return P4CompleteRequest( Irp, STATUS_SUCCESS, 0 );
  55. }