WdfDeviceInitRegisterPowerPolicyStateChangeCallback function (wdfdevice.h)

[Applies to KMDF only]

Note

This method is for Microsoft internal use only.

The WdfDeviceInitRegisterPowerPolicyStateChangeCallback method registers a driver-supplied event callback function that the framework calls when a device's power policy state machine changes state.

Syntax

NTSTATUS WdfDeviceInitRegisterPowerPolicyStateChangeCallback(
  [in] PWDFDEVICE_INIT                                       DeviceInit,
  [in] WDF_DEVICE_POWER_POLICY_STATE                         PowerPolicyState,
  [in] PFN_WDF_DEVICE_POWER_POLICY_STATE_CHANGE_NOTIFICATION EvtDevicePowerPolicyStateChange,
  [in] ULONG                                                 CallbackTypes
);

Parameters

[in] DeviceInit

A caller-supplied pointer to a WDFDEVICE_INIT structure.

[in] PowerPolicyState

A WDF_DEVICE_POWER_POLICY_STATE enumerator that identifies the power policy machine state for which the driver is requesting notification.

[in] EvtDevicePowerPolicyStateChange

A caller-supplied pointer to the driver's EvtDevicePowerPolicyStateChange event callback function.

[in] CallbackTypes

An ORed combination of WDF_STATE_NOTIFICATION_TYPE-typed enumerators.

Return value

If WdfDeviceInitRegisterPowerPolicyStateChangeCallback encounters no errors, it returns STATUS_SUCCESS. Additional return values include:

Return code Description
STATUS_INVALID_PARAMETER
An invalid parameter was detected.
STATUS_INSUFFICIENT_RESOURCES
There is insufficient memory to complete the operation.

Remarks

If your driver calls WdfDeviceInitRegisterPowerPolicyStateChangeCallback, it must do so before it calls WdfDeviceCreate.

For more information about WdfDeviceInitRegisterPowerPolicyStateChangeCallback, see State Machines in the Framework.

Examples

The following code example registers an event callback function that the framework will call when the device's power policy state machine changes state.

status = WdfDeviceInitRegisterPowerPolicyStateChangeCallback(
                                 DeviceInit,
                                 WdfDevStatePwrPolCheckPowerPageable,
                                 PciDrvPowerPolicyStateChangeCallback,
                                 StateNotificationAllStates
                                 );

Requirements

Requirement Value
Target Platform Universal
Minimum KMDF version 1.0
Header wdfdevice.h (include Wdf.h)
Library Wdf01000.sys (see Framework Library Versioning.)
IRQL PASSIVE_LEVEL
DDI compliance rules ChildDeviceInitAPI(kmdf), DeviceInitAPI(kmdf), DriverCreate(kmdf), InitFreeDeviceCallback(kmdf), InitFreeDeviceCreate(kmdf), InitFreeNull(kmdf), KmdfIrql(kmdf), KmdfIrql2(kmdf), KmdfIrqlExplicit(kmdf), PdoDeviceInitAPI(kmdf), PdoInitFreeDeviceCallback(kmdf), PdoInitFreeDeviceCreate(kmdf)