pm: device: remove usage of local states
The device PM subsystem already holds the device state, so there is no need to keep duplicates inside the device. The pm_device_state_get has been refactored to just return the device state. Note that this is still not safe, but the same applied to the previous implementation. This problem will be addressed later. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
1c0ed94601
commit
c2cf1ad203
48 changed files with 198 additions and 715 deletions
|
@ -63,9 +63,6 @@ struct st7735r_data {
|
|||
const struct device *reset_dev;
|
||||
uint16_t x_offset;
|
||||
uint16_t y_offset;
|
||||
#ifdef CONFIG_PM_DEVICE
|
||||
enum pm_device_state pm_state;
|
||||
#endif
|
||||
};
|
||||
|
||||
static void st7735r_set_lcd_margins(struct st7735r_data *data,
|
||||
|
@ -462,10 +459,6 @@ static int st7735r_init(const struct device *dev)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_DEVICE
|
||||
data->pm_state = PM_DEVICE_STATE_ACTIVE;
|
||||
#endif
|
||||
|
||||
data->cmd_data_dev = device_get_binding(config->cmd_data.name);
|
||||
if (data->cmd_data_dev == NULL) {
|
||||
LOG_ERR("Could not get GPIO port for cmd/DATA port");
|
||||
|
@ -519,22 +512,14 @@ static int st7735r_pm_control(const struct device *dev, uint32_t ctrl_command,
|
|||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
data->pm_state = PM_DEVICE_STATE_ACTIVE;
|
||||
} else {
|
||||
ret = st7735r_enter_sleep(data);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
data->pm_state = PM_DEVICE_STATE_LOW_POWER;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case PM_DEVICE_STATE_GET:
|
||||
*state = data->pm_state;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
ret = -EINVAL;
|
||||
}
|
||||
|
|
|
@ -52,9 +52,6 @@ struct st7789v_data {
|
|||
uint16_t width;
|
||||
uint16_t x_offset;
|
||||
uint16_t y_offset;
|
||||
#ifdef CONFIG_PM_DEVICE
|
||||
enum pm_device_state pm_state;
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef CONFIG_ST7789V_RGB565
|
||||
|
@ -375,10 +372,6 @@ static int st7789v_init(const struct device *dev)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PM_DEVICE
|
||||
data->pm_state = PM_DEVICE_STATE_ACTIVE;
|
||||
#endif
|
||||
|
||||
data->cmd_data_gpio = device_get_binding(
|
||||
DT_INST_GPIO_LABEL(0, cmd_data_gpios));
|
||||
if (data->cmd_data_gpio == NULL) {
|
||||
|
@ -418,17 +411,12 @@ static int st7789v_pm_control(const struct device *dev, uint32_t ctrl_command,
|
|||
case DEVICE_PM_SET_POWER_STATE:
|
||||
if (*state == PM_DEVICE_STATE_ACTIVE) {
|
||||
st7789v_exit_sleep(data);
|
||||
data->pm_state = PM_DEVICE_STATE_ACTIVE;
|
||||
ret = 0;
|
||||
} else {
|
||||
st7789v_enter_sleep(data);
|
||||
data->pm_state = PM_DEVICE_STATE_LOW_POWER;
|
||||
ret = 0;
|
||||
}
|
||||
break;
|
||||
case PM_DEVICE_STATE_GET:
|
||||
*state = data->pm_state;
|
||||
break;
|
||||
default:
|
||||
ret = -EINVAL;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue