NTSTATUS NTAPI Bus_Power ( PDEVICE_OBJECT DeviceObject, PIRP Irp ) { PIO_STACK_LOCATION irpStack; NTSTATUS status; PCOMMON_DEVICE_DATA commonData; status = STATUS_SUCCESS; irpStack = IoGetCurrentIrpStackLocation (Irp); ASSERT (IRP_MJ_POWER == irpStack->MajorFunction); commonData = (PCOMMON_DEVICE_DATA) DeviceObject->DeviceExtension; if (commonData->IsFDO) { DPRINT("FDO %s IRP:0x%p %s %s\n", PowerMinorFunctionString(irpStack->MinorFunction), Irp, DbgSystemPowerString(commonData->SystemPowerState), DbgDevicePowerString(commonData->DevicePowerState)); status = Bus_FDO_Power ((PFDO_DEVICE_DATA)DeviceObject->DeviceExtension, Irp); } else { DPRINT("PDO %s IRP:0x%p %s %s\n", PowerMinorFunctionString(irpStack->MinorFunction), Irp, DbgSystemPowerString(commonData->SystemPowerState), DbgDevicePowerString(commonData->DevicePowerState)); status = Bus_PDO_Power ((PPDO_DEVICE_DATA)DeviceObject->DeviceExtension, Irp); } return status; }
NTSTATUS Bus_Power ( __in PDEVICE_OBJECT DeviceObject, __in PIRP Irp ) /*++ Handles power Irps sent to both FDO and child PDOs. Note: Currently we do not implement full power handling for the FDO. Arguments: DeviceObject - Pointer to the device object. Irp - Pointer to the irp. Return Value: NT status is returned. --*/ { PIO_STACK_LOCATION irpStack; NTSTATUS status; PCOMMON_DEVICE_DATA commonData; status = STATUS_SUCCESS; irpStack = IoGetCurrentIrpStackLocation (Irp); ASSERT (IRP_MJ_POWER == irpStack->MajorFunction); commonData = (PCOMMON_DEVICE_DATA) DeviceObject->DeviceExtension; // // If the device has been removed, the driver should // not pass the IRP down to the next lower driver. // if (commonData->DevicePnPState == Deleted) { PoStartNextPowerIrp (Irp); Irp->IoStatus.Status = status = STATUS_NO_SUCH_DEVICE ; IoCompleteRequest (Irp, IO_NO_INCREMENT); return status; } if (commonData->IsFDO) { Bus_KdPrint (commonData, BUS_DBG_POWER_TRACE, ("FDO %s IRP:0x%p %s %s\n", PowerMinorFunctionString(irpStack->MinorFunction), Irp, DbgSystemPowerString(commonData->SystemPowerState), DbgDevicePowerString(commonData->DevicePowerState))); status = Bus_FDO_Power ((PFDO_DEVICE_DATA)DeviceObject->DeviceExtension, Irp); } else { Bus_KdPrint (commonData, BUS_DBG_POWER_TRACE, ("PDO %s IRP:0x%p %s %s\n", PowerMinorFunctionString(irpStack->MinorFunction), Irp, DbgSystemPowerString(commonData->SystemPowerState), DbgDevicePowerString(commonData->DevicePowerState))); status = Bus_PDO_Power ((PPDO_DEVICE_DATA)DeviceObject->DeviceExtension, Irp); } return status; }