pm: cleanup pm control callback implementations
- Return -ENOTSUP if the requested state is not supported - Remove redundant "noop style" functions. - Use switch everywhere to handle requested state (not necessary in all drivers, but better take off with consistency in place after current changes). Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
d41dadc569
commit
495672ab62
33 changed files with 263 additions and 334 deletions
|
@ -494,27 +494,22 @@ static int st7735r_init(const struct device *dev)
|
|||
}
|
||||
|
||||
#ifdef CONFIG_PM_DEVICE
|
||||
static int st7735r_enter_sleep(struct st7735r_data *data)
|
||||
{
|
||||
return st7735r_transmit(data, ST7735R_CMD_SLEEP_IN, NULL, 0);
|
||||
}
|
||||
|
||||
static int st7735r_pm_control(const struct device *dev,
|
||||
enum pm_device_state state)
|
||||
{
|
||||
int ret = 0;
|
||||
struct st7735r_data *data = (struct st7735r_data *)dev->data;
|
||||
|
||||
if (state == PM_DEVICE_STATE_ACTIVE) {
|
||||
switch (state) {
|
||||
case PM_DEVICE_STATE_ACTIVE:
|
||||
ret = st7735r_exit_sleep(data);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
} else {
|
||||
ret = st7735r_enter_sleep(data);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
break;
|
||||
case PM_DEVICE_STATE_SUSPENDED:
|
||||
ret = st7735r_transmit(data, ST7735R_CMD_SLEEP_IN, NULL, 0);
|
||||
break;
|
||||
default:
|
||||
ret = -ENOTSUP;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -396,23 +396,25 @@ static int st7789v_init(const struct device *dev)
|
|||
}
|
||||
|
||||
#ifdef CONFIG_PM_DEVICE
|
||||
static void st7789v_enter_sleep(struct st7789v_data *data)
|
||||
{
|
||||
st7789v_transmit(data, ST7789V_CMD_SLEEP_IN, NULL, 0);
|
||||
}
|
||||
|
||||
static int st7789v_pm_control(const struct device *dev,
|
||||
enum pm_device_state state)
|
||||
{
|
||||
struct st7789v_data *data = (struct st7789v_data *)dev->data;
|
||||
int ret = 0;
|
||||
|
||||
if (state == PM_DEVICE_STATE_ACTIVE) {
|
||||
switch (state) {
|
||||
case PM_DEVICE_STATE_ACTIVE:
|
||||
st7789v_exit_sleep(data);
|
||||
} else {
|
||||
st7789v_enter_sleep(data);
|
||||
break;
|
||||
case PM_DEVICE_STATE_SUSPENDED:
|
||||
ret = st7789v_transmit(data, ST7789V_CMD_SLEEP_IN, NULL, 0);
|
||||
break;
|
||||
default:
|
||||
ret = -ENOTSUP;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
#endif /* CONFIG_PM_DEVICE */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue