pm: device_runtime: Reset usage count on enable

Since enabling runtime pm on a device sets the device state to
suspended. The usage count has to be zeroed otherwise we may
have an inconsistency.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
Flavio Ceolin 2021-12-10 13:15:59 -08:00 committed by Anas Nashif
commit 4184678613

View file

@ -186,6 +186,7 @@ void pm_device_runtime_enable(const struct device *dev)
k_work_init_delayable(&pm->work, runtime_suspend_work);
}
pm->state = PM_DEVICE_STATE_SUSPENDED;
pm->usage = 0U;
atomic_set_bit(&pm->flags, PM_DEVICE_FLAG_RUNTIME_ENABLED);