pm: policy: move constraints to policy API

The pm_constraint_* APIs were effectively used by the policy manager
only. This patch renames the API to the policy namespace and makes its
naming more explicit:

- pm_constraint_set -> pm_policy_state_lock_get()
- pm_constraint_release -> pm_policy_state_lock_put()
- pm_constraint_get -> pm_policy_state_lock_is_active()

The reason for these changes is that constraints can be of many types:
allow/disallow states, impose latency requirements, etc. The new naming
also makes explicit that the API calls will influence the PM policy
behavior.

All drivers and documentation have been updated accordingly.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
Gerard Marull-Paretas 2022-01-20 16:06:28 +01:00 committed by Carles Cufí
commit 5a71eeb35c
23 changed files with 191 additions and 195 deletions

View file

@ -11,7 +11,6 @@
#include <drivers/uart.h>
#include <kernel.h>
#include <pm/device.h>
#include <pm/pm.h>
#include <pm/policy.h>
#include <soc.h>
@ -57,7 +56,7 @@ void uart1_wui_isr(const struct device *gpio, struct gpio_callback *cb,
* The pm state of it8xxx2 chip only supports standby, so here we
* can directly set the constraint for standby.
*/
pm_constraint_set(PM_STATE_STANDBY);
pm_policy_state_lock_get(PM_STATE_STANDBY);
k_work_reschedule(&uart_console_data->rx_refresh_timeout_work, delay);
#endif
}
@ -77,7 +76,7 @@ void uart2_wui_isr(const struct device *gpio, struct gpio_callback *cb,
* The pm state of it8xxx2 chip only supports standby, so here we
* can directly set the constraint for standby.
*/
pm_constraint_set(PM_STATE_STANDBY);
pm_policy_state_lock_get(PM_STATE_STANDBY);
k_work_reschedule(&uart_console_data->rx_refresh_timeout_work, delay);
#endif
}
@ -117,7 +116,7 @@ static void uart_it8xxx2_rx_refresh_timeout(struct k_work *work)
{
ARG_UNUSED(work);
pm_constraint_release(PM_STATE_STANDBY);
pm_policy_state_lock_put(PM_STATE_STANDBY);
}
#endif
#endif /* CONFIG_PM_DEVICE */