pm: use actions for device PM control

Instead of passing target states, use actions for device PM control.
Actions represent better the meaning of the callback argument.
Furthermore, they are more future proof as they can be suitable for
other PM actions that have no direct mapping to a state. If we compare
with Linux, we could have a multi-stage suspend/resume. Such scenario
would not have a good mapping when using target states.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
Gerard Marull-Paretas 2021-07-05 15:13:40 +02:00 committed by Anas Nashif
commit 7ccc1a41bc
40 changed files with 176 additions and 145 deletions

View file

@ -495,16 +495,16 @@ static int st7735r_init(const struct device *dev)
#ifdef CONFIG_PM_DEVICE
static int st7735r_pm_control(const struct device *dev,
enum pm_device_state state)
enum pm_device_action action)
{
int ret = 0;
struct st7735r_data *data = (struct st7735r_data *)dev->data;
switch (state) {
case PM_DEVICE_STATE_ACTIVE:
switch (action) {
case PM_DEVICE_ACTION_RESUME:
ret = st7735r_exit_sleep(data);
break;
case PM_DEVICE_STATE_SUSPENDED:
case PM_DEVICE_ACTION_SUSPEND:
ret = st7735r_transmit(data, ST7735R_CMD_SLEEP_IN, NULL, 0);
break;
default:

View file

@ -397,16 +397,16 @@ static int st7789v_init(const struct device *dev)
#ifdef CONFIG_PM_DEVICE
static int st7789v_pm_control(const struct device *dev,
enum pm_device_state state)
enum pm_device_action action)
{
struct st7789v_data *data = (struct st7789v_data *)dev->data;
int ret = 0;
switch (state) {
case PM_DEVICE_STATE_ACTIVE:
switch (action) {
case PM_DEVICE_ACTION_RESUME:
st7789v_exit_sleep(data);
break;
case PM_DEVICE_STATE_SUSPENDED:
case PM_DEVICE_ACTION_SUSPEND:
ret = st7789v_transmit(data, ST7789V_CMD_SLEEP_IN, NULL, 0);
break;
default: