{
NTSTATUS ntStatus;
POWER_STATE powerState;
KEVENT irpCompletionEvent;
PIRP_COMPLETION_CONTEXT irpContext;
FreeBT_DbgPrint(3, ("FBTUSB: IdleNotificationCallback: Entered\n"));
//// Dont idle, if the device was just disconnected or being stopped// i.e. return for the following DeviceState(s)// NotStarted, Stopped, PendingStop, PendingRemove, SurpriseRemoved, Removed//if(DeviceExtension->DeviceState != Working) {
return;
}
//// If there is not already a WW IRP pending, submit one now//if(DeviceExtension->WaitWakeEnable) {
IssueWaitWake(DeviceExtension);
}
//// power down the device//
irpContext = (PIRP_COMPLETION_CONTEXT)
ExAllocatePool(NonPagedPool,
sizeof(IRP_COMPLETION_CONTEXT));
if(!irpContext) {
FreeBT_DbgPrint(1, ("FBTUSB: IdleNotificationCallback: Failed to alloc memory for irpContext\n"));
ntStatus = STATUS_INSUFFICIENT_RESOURCES;
}
else {
//// increment the count. In the HoldIoRequestWorkerRoutine, the// count is decremented twice (one for the system Irp and the// other for the device Irp. An increment here compensates for// the sytem irp..The decrement corresponding to this increment// is in the completion function//FreeBT_DbgPrint(3, ("FBTUSB: IdleNotificationCallback::"));
FreeBT_IoIncrement(DeviceExtension);
powerState.DeviceState = (DEVICE_POWER_STATE) DeviceExtension->PowerDownLevel;
KeInitializeEvent(&irpCompletionEvent, NotificationEvent, FALSE);
irpContext->DeviceExtension = DeviceExtension;
irpContext->Event = &irpCompletionEvent;
ntStatus = PoRequestPowerIrp(
DeviceExtension->PhysicalDeviceObject,
IRP_MN_SET_POWER,
powerState,
(PREQUEST_POWER_COMPLETE) PoIrpCompletionFunc,
irpContext,
NULL);
if(STATUS_PENDING == ntStatus) {
FreeBT_DbgPrint(3, ("FBTUSB: IdleNotificationCallback::""waiting for the power irp to complete\n"));
KeWaitForSingleObject(&irpCompletionEvent,
Executive,
KernelMode,
FALSE,
NULL);
}
}
if(!NT_SUCCESS(ntStatus)) {
if(irpContext) {
ExFreePool(irpContext);
}
}
FreeBT_DbgPrint(3, ("FBTUSB: IdleNotificationCallback: Leaving\n"));
}
Generated on Mon May 28 2012 05:22:03 for ReactOS by
1.7.6.1
ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.