Skip to content

Commit 6d273f4

Browse files
gmarullnashif
authored andcommitted
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 <[email protected]>
1 parent 495672a commit 6d273f4

File tree

10 files changed

+3
-19
lines changed

10 files changed

+3
-19
lines changed

drivers/flash/spi_flash_at45.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,8 +637,6 @@ static int spi_flash_at45_pm_control(const struct device *dev,
637637
break;
638638

639639
case PM_DEVICE_STATE_SUSPENDED:
640-
__fallthrough;
641-
case PM_DEVICE_STATE_OFF:
642640
acquire(dev);
643641
power_down_op(dev,
644642
dev_config->use_udpd ? CMD_ENTER_UDPD : CMD_ENTER_DPD,

drivers/i2c/i2c_nrfx_twi.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,6 @@ static int twi_nrfx_pm_control(const struct device *dev,
231231
break;
232232

233233
case PM_DEVICE_STATE_SUSPENDED:
234-
__fallthrough;
235-
case PM_DEVICE_STATE_OFF:
236234
nrfx_twi_uninit(&get_dev_config(dev)->twi);
237235
break;
238236

drivers/i2c/i2c_nrfx_twim.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,6 @@ static int twim_nrfx_pm_control(const struct device *dev,
269269
break;
270270

271271
case PM_DEVICE_STATE_SUSPENDED:
272-
__fallthrough;
273-
case PM_DEVICE_STATE_OFF:
274272
nrfx_twim_uninit(&get_dev_config(dev)->twim);
275273
break;
276274

drivers/interrupt_controller/intc_ioapic.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,6 @@ static int ioapic_device_ctrl(const struct device *dev,
319319
ret = ioapic_resume_from_suspend(dev);
320320
break;
321321
case PM_DEVICE_STATE_SUSPENDED:
322-
__fallthrough;
323-
case PM_DEVICE_STATE_OFF:
324322
ret = ioapic_suspend(dev);
325323
break;
326324
default:

drivers/modem/hl7800.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3505,7 +3505,7 @@ static void shutdown_uart(void)
35053505
HL7800_IO_DBG_LOG("Power OFF the UART");
35063506
uart_irq_rx_disable(ictx.mdm_ctx.uart_dev);
35073507
rc = pm_device_state_set(ictx.mdm_ctx.uart_dev,
3508-
PM_DEVICE_STATE_OFF);
3508+
PM_DEVICE_STATE_SUSPENDED);
35093509
if (rc) {
35103510
LOG_ERR("Error disabling UART peripheral (%d)", rc);
35113511
}

drivers/pwm/pwm_nrfx.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,6 @@ static int pwm_nrfx_pm_control(const struct device *dev,
301301
err = pwm_nrfx_init(dev);
302302
break;
303303
case PM_DEVICE_STATE_SUSPENDED:
304-
__fallthrough;
305-
case PM_DEVICE_STATE_OFF:
306304
pwm_nrfx_uninit(dev);
307305
break;
308306
default:

drivers/sensor/bme280/bme280.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ static int bme280_sample_fetch(const struct device *dev,
197197
#ifdef CONFIG_PM_DEVICE
198198
enum pm_device_state state;
199199
(void)pm_device_state_get(dev, &state);
200-
/* Do not allow sample fetching from OFF state */
201-
if (state == PM_DEVICE_STATE_OFF)
200+
/* Do not allow sample fetching from suspended state */
201+
if (state == PM_DEVICE_STATE_SUSPENDED)
202202
return -EIO;
203203
#endif
204204

@@ -420,8 +420,6 @@ int bme280_pm_ctrl(const struct device *dev, enum pm_device_state state)
420420
ret = bme280_chip_init(dev);
421421
break;
422422
case PM_DEVICE_STATE_SUSPENDED:
423-
__fallthrough;
424-
case PM_DEVICE_STATE_OFF:
425423
/* Put the chip into sleep mode */
426424
ret = bme280_reg_write(dev,
427425
BME280_REG_CTRL_MEAS,

drivers/sensor/bmp388/bmp388.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,8 +559,6 @@ static int bmp388_device_ctrl(const struct device *dev,
559559
reg_val = BMP388_PWR_CTRL_MODE_NORMAL;
560560
break;
561561
case PM_DEVICE_STATE_SUSPENDED:
562-
__fallthrough;
563-
case PM_DEVICE_STATE_OFF:
564562
reg_val = BMP388_PWR_CTRL_MODE_SLEEP;
565563
break;
566564
default:

drivers/spi/spi_nrfx_spi.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,6 @@ static int spi_nrfx_pm_control(const struct device *dev,
292292
break;
293293

294294
case PM_DEVICE_STATE_SUSPENDED:
295-
case PM_DEVICE_STATE_OFF:
296295
nrfx_spi_uninit(&config->spi);
297296
break;
298297

drivers/spi/spi_nrfx_spim.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,6 @@ static int spim_nrfx_pm_control(const struct device *dev,
339339
break;
340340

341341
case PM_DEVICE_STATE_SUSPENDED:
342-
case PM_DEVICE_STATE_OFF:
343342
nrfx_spim_uninit(&config->spim);
344343
break;
345344

0 commit comments

Comments
 (0)