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

@ -637,8 +637,6 @@ static int spi_flash_at45_pm_control(const struct device *dev,
break;
case PM_DEVICE_STATE_SUSPENDED:
__fallthrough;
case PM_DEVICE_STATE_OFF:
acquire(dev);
power_down_op(dev,
dev_config->use_udpd ? CMD_ENTER_UDPD : CMD_ENTER_DPD,

View file

@ -231,8 +231,6 @@ static int twi_nrfx_pm_control(const struct device *dev,
break;
case PM_DEVICE_STATE_SUSPENDED:
__fallthrough;
case PM_DEVICE_STATE_OFF:
nrfx_twi_uninit(&get_dev_config(dev)->twi);
break;

View file

@ -269,8 +269,6 @@ static int twim_nrfx_pm_control(const struct device *dev,
break;
case PM_DEVICE_STATE_SUSPENDED:
__fallthrough;
case PM_DEVICE_STATE_OFF:
nrfx_twim_uninit(&get_dev_config(dev)->twim);
break;

View file

@ -319,8 +319,6 @@ static int ioapic_device_ctrl(const struct device *dev,
ret = ioapic_resume_from_suspend(dev);
break;
case PM_DEVICE_STATE_SUSPENDED:
__fallthrough;
case PM_DEVICE_STATE_OFF:
ret = ioapic_suspend(dev);
break;
default:

View file

@ -3505,7 +3505,7 @@ static void shutdown_uart(void)
HL7800_IO_DBG_LOG("Power OFF the UART");
uart_irq_rx_disable(ictx.mdm_ctx.uart_dev);
rc = pm_device_state_set(ictx.mdm_ctx.uart_dev,
PM_DEVICE_STATE_OFF);
PM_DEVICE_STATE_SUSPENDED);
if (rc) {
LOG_ERR("Error disabling UART peripheral (%d)", rc);
}

View file

@ -301,8 +301,6 @@ static int pwm_nrfx_pm_control(const struct device *dev,
err = pwm_nrfx_init(dev);
break;
case PM_DEVICE_STATE_SUSPENDED:
__fallthrough;
case PM_DEVICE_STATE_OFF:
pwm_nrfx_uninit(dev);
break;
default:

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,

View file

@ -559,8 +559,6 @@ static int bmp388_device_ctrl(const struct device *dev,
reg_val = BMP388_PWR_CTRL_MODE_NORMAL;
break;
case PM_DEVICE_STATE_SUSPENDED:
__fallthrough;
case PM_DEVICE_STATE_OFF:
reg_val = BMP388_PWR_CTRL_MODE_SLEEP;
break;
default:

View file

@ -292,7 +292,6 @@ static int spi_nrfx_pm_control(const struct device *dev,
break;
case PM_DEVICE_STATE_SUSPENDED:
case PM_DEVICE_STATE_OFF:
nrfx_spi_uninit(&config->spi);
break;

View file

@ -339,7 +339,6 @@ static int spim_nrfx_pm_control(const struct device *dev,
break;
case PM_DEVICE_STATE_SUSPENDED:
case PM_DEVICE_STATE_OFF:
nrfx_spim_uninit(&config->spim);
break;