pm: fix incorrect usages of PM_DEVICE_STATE_OFF

According to the documentation the OFF state has to be used when the
devices is fully turned off, ie, power removed. Most drivers were using
a sort of fall-through for all non-active states, leading to behaviors
not following the specifications.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
Gerard Marull-Paretas 2021-07-05 10:54:01 +02:00 committed by Anas Nashif
commit 6d273f49bd
10 changed files with 3 additions and 19 deletions

View file

@ -197,8 +197,8 @@ static int bme280_sample_fetch(const struct device *dev,
#ifdef CONFIG_PM_DEVICE
enum pm_device_state state;
(void)pm_device_state_get(dev, &state);
/* Do not allow sample fetching from OFF state */
if (state == PM_DEVICE_STATE_OFF)
/* Do not allow sample fetching from suspended state */
if (state == PM_DEVICE_STATE_SUSPENDED)
return -EIO;
#endif
@ -420,8 +420,6 @@ int bme280_pm_ctrl(const struct device *dev, enum pm_device_state state)
ret = bme280_chip_init(dev);
break;
case PM_DEVICE_STATE_SUSPENDED:
__fallthrough;
case PM_DEVICE_STATE_OFF:
/* Put the chip into sleep mode */
ret = bme280_reg_write(dev,
BME280_REG_CTRL_MEAS,