---
title: SetPowerState
framework: driverkit
role: symbol
role_heading: Instance Method
path: driverkit/ioservice/setpowerstate
---

# SetPowerState

Updates the service in response to power-related changes for a provider.

## Declaration

```occ
virtual kern_return_t SetPowerState(uint32_t powerFlags);
```

## Parameters

- `powerFlags`: The new power state for the service’s provider object. Configure your driver appropriately for the new state. For a list of possible values, see doc://com.apple.driverkit/documentation/DriverKit/3325571-service_power_capabilities.

## Return Value

Return Value kIOReturnSuccess on success, or another value if an error occurs. For a list of error codes, see Error Codes.

## Discussion

Discussion DriverKit calls this method to notify your service when the power state of its provider changes. Implement this method in your service object and use it to put your driver in a safe state for the new power setting. Call super as the last step in your implementation.

## See Also

### Responding to Power-Level Changes

- [ChangePowerState](driverkit/ioservice/changepowerstate.md)
- [Service Power Capabilities](driverkit/3325571-service_power_capabilities.md)
