pm: device_runtime: suspend device on enable

The pm_device_runtime_enable did not suspend devices, so it assumed that
the device was in a physically suspended state. This change makes sure
that device is left in a suspended state if the device is initially
active.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
Gerard Marull-Paretas 2021-12-02 12:31:06 +01:00 committed by Carles Cufí
commit 91b8abfb4d
4 changed files with 34 additions and 7 deletions

View file

@ -25,6 +25,9 @@ extern "C" {
/**
* @brief Enable device runtime PM
*
* This function will enable runtime PM on the given device. If the device is
* in #PM_DEVICE_STATE_ACTIVE state, the device will be suspended.
*
* @funcprops \pre_kernel_ok
*
* @param dev Device instance.
@ -32,6 +35,9 @@ extern "C" {
* @retval 0 If the device runtime PM is enabled successfully.
* @retval -EPERM If device has power state locked.
* @retval -ENOSYS If the functionality is not available.
* @retval -errno Other negative errno, result of suspending the device.
*
* @see pm_device_runtime_init_suspended()
*/
int pm_device_runtime_enable(const struct device *dev);