WdfDeviceInitSetPowerPolicyOwnership function (wdfdevice.h)

[Applies to KMDF and UMDF]

The WdfDeviceInitSetPowerPolicyOwnership method establishes whether the calling driver is, or is not, the power policy owner for a specified device.

Syntax

void WdfDeviceInitSetPowerPolicyOwnership(
  [in] PWDFDEVICE_INIT DeviceInit,
  [in] BOOLEAN         IsPowerPolicyOwner
);

Parameters

[in] DeviceInit

A caller-supplied pointer to a WDFDEVICE_INIT structure.

[in] IsPowerPolicyOwner

A Boolean value that indicates whether the calling driver is the power policy owner. If TRUE, the calling driver is the power policy owner. If FALSE, it is not the power policy owner.

Return value

None

Remarks

If you are writing a framework-based function driver, the framework automatically establishes your driver as the power policy owner. (If the device operates in raw mode, the bus driver is the default power policy owner.)

To change the default power policy owner, the following two drivers must call WdfDeviceInitSetPowerPolicyOwnership:

  • The default power policy owner must call WdfDeviceInitSetPowerPolicyOwnership with IsPowerPolicyOwner set to FALSE.
  • The driver that you want to be the power policy owner must call WdfDeviceInitSetPowerPolicyOwnership with IsPowerPolicyOwner set to TRUE.
If you are writing a framework-based bus driver or filter driver, and if the device does not operate in raw mode, your driver will not be the power policy owner unless it calls WdfDeviceInitSetPowerPolicyOwnership.

Only one driver in each stack can be the power policy owner, so you must ensure that only one driver calls WdfDeviceInitSetPowerPolicyOwnership with IsPowerPolicyOwner set to TRUE.

If your driver calls WdfDeviceInitSetPowerPolicyOwnership, it must do so before it calls WdfDeviceCreate. For more information, see Creating a Framework Device Object.

For more information about calling WdfDeviceInitSetPowerPolicyOwnership, see Power Policy Ownership.

Examples

The following code example is from the Serial sample driver. This example checks a registry value to determine if a driver should be the power policy owner. If the driver should not be the power policy owner, the example calls WdfDeviceInitSetPowerPolicyOwnership.

//
// Call subroutine that checks a registry value.
//
SerialGetFdoRegistryKeyValue(
                             DeviceInit,
                             L"SerialRelinquishPowerPolicy",
                             &relinquishPowerPolicy
                             );
//
// If the registry value is TRUE, do not own power policy.
//
if(relinquishPowerPolicy) {
    WdfDeviceInitSetPowerPolicyOwnership(
                                         DeviceInit,
                                         FALSE
                                         );
}

Requirements

Requirement Value
Target Platform Universal
Minimum KMDF version 1.0
Minimum UMDF version 2.0
Header wdfdevice.h (include Wdf.h)
Library Wdf01000.sys (KMDF); WUDFx02000.dll (UMDF)
IRQL <= DISPATCH_LEVEL
DDI compliance rules ChildDeviceInitAPI(kmdf), DeviceInitAPI(kmdf), DriverCreate(kmdf), FDOPowerPolicyOwnerAPI(kmdf), KmdfIrql(kmdf), KmdfIrql2(kmdf), KmdfIrqlExplicit(kmdf), PdoDeviceInitAPI(kmdf)

See also

WdfDeviceCreate