Skip to content

Commit 2c7b763

Browse files
gmarullnashif
authored andcommitted
pm: replace DEVICE_PM_* states with PM_DEVICE_*
Prefix device PM states with PM. Signed-off-by: Gerard Marull-Paretas <[email protected]>
1 parent 2d39c01 commit 2c7b763

File tree

52 files changed

+331
-331
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+331
-331
lines changed

doc/reference/power_management/index.rst

+8-8
Original file line numberDiff line numberDiff line change
@@ -215,20 +215,20 @@ registers, clocks, memory etc.
215215

216216
The four device power states:
217217

218-
:code:`DEVICE_PM_ACTIVE_STATE`
218+
:code:`PM_DEVICE_ACTIVE_STATE`
219219

220220
Normal operation of the device. All device context is retained.
221221

222-
:code:`DEVICE_PM_LOW_POWER_STATE`
222+
:code:`PM_DEVICE_LOW_POWER_STATE`
223223

224224
Device context is preserved by the HW and need not be restored by the driver.
225225

226-
:code:`DEVICE_PM_SUSPEND_STATE`
226+
:code:`PM_DEVICE_SUSPEND_STATE`
227227

228228
Most device context is lost by the hardware. Device drivers must save and
229229
restore or reinitialize any context lost by the hardware.
230230

231-
:code:`DEVICE_PM_OFF_STATE`
231+
:code:`PM_DEVICE_OFF_STATE`
232232

233233
Power has been fully removed from the device. The device context is lost
234234
when this state is entered. Need to reinitialize the device when powering
@@ -241,8 +241,8 @@ Zephyr RTOS power management subsystem provides a control function interface
241241
to device drivers to indicate power management operations to perform.
242242
The supported PM control commands are:
243243

244-
* DEVICE_PM_SET_POWER_STATE
245-
* DEVICE_PM_GET_POWER_STATE
244+
* PM_DEVICE_SET_POWER_STATE
245+
* PM_DEVICE_GET_POWER_STATE
246246

247247
Each device driver defines:
248248

@@ -298,7 +298,7 @@ Device Set Power State
298298
int device_set_power_state(const struct device *dev, uint32_t device_power_state, device_pm_cb cb, void *arg);
299299
300300
Calls the :c:func:`device_pm_control()` handler function implemented by the
301-
device driver with DEVICE_PM_SET_POWER_STATE command.
301+
device driver with PM_DEVICE_SET_POWER_STATE command.
302302

303303
Device Get Power State
304304
----------------------
@@ -308,7 +308,7 @@ Device Get Power State
308308
int device_get_power_state(const struct device *dev, uint32_t * device_power_state);
309309
310310
Calls the :c:func:`device_pm_control()` handler function implemented by the
311-
device driver with DEVICE_PM_GET_POWER_STATE command.
311+
device driver with PM_DEVICE_GET_POWER_STATE command.
312312

313313
Busy Status Indication
314314
======================

drivers/display/display_st7735r.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ static int st7735r_init(const struct device *dev)
476476
}
477477

478478
#ifdef CONFIG_DEVICE_POWER_MANAGEMENT
479-
data->pm_state = DEVICE_PM_ACTIVE_STATE;
479+
data->pm_state = PM_DEVICE_ACTIVE_STATE;
480480
#endif
481481

482482
data->cmd_data_dev = device_get_binding(config->cmd_data.name);
@@ -526,24 +526,24 @@ static int st7735r_pm_control(const struct device *dev, uint32_t ctrl_command,
526526
struct st7735r_data *data = (struct st7735r_data *)dev->data;
527527

528528
switch (ctrl_command) {
529-
case DEVICE_PM_SET_POWER_STATE:
530-
if (*((uint32_t *)context) == DEVICE_PM_ACTIVE_STATE) {
529+
case PM_DEVICE_SET_POWER_STATE:
530+
if (*((uint32_t *)context) == PM_DEVICE_ACTIVE_STATE) {
531531
ret = st7735r_exit_sleep(data);
532532
if (ret < 0) {
533533
return ret;
534534
}
535-
data->pm_state = DEVICE_PM_ACTIVE_STATE;
535+
data->pm_state = PM_DEVICE_ACTIVE_STATE;
536536
} else {
537537
ret = st7735r_enter_sleep(data);
538538
if (ret < 0) {
539539
return ret;
540540
}
541-
data->pm_state = DEVICE_PM_LOW_POWER_STATE;
541+
data->pm_state = PM_DEVICE_LOW_POWER_STATE;
542542
}
543543

544544
break;
545545

546-
case DEVICE_PM_GET_POWER_STATE:
546+
case PM_DEVICE_GET_POWER_STATE:
547547
*((uint32_t *)context) = data->pm_state;
548548

549549
break;

drivers/display/display_st7789v.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ static int st7789v_init(const struct device *dev)
376376
#endif
377377

378378
#ifdef CONFIG_PM_DEVICE
379-
data->pm_state = DEVICE_PM_ACTIVE_STATE;
379+
data->pm_state = PM_DEVICE_ACTIVE_STATE;
380380
#endif
381381

382382
data->cmd_data_gpio = device_get_binding(
@@ -415,18 +415,18 @@ static int st7789v_pm_control(const struct device *dev, uint32_t ctrl_command,
415415
struct st7789v_data *data = (struct st7789v_data *)dev->data;
416416

417417
switch (ctrl_command) {
418-
case DEVICE_PM_SET_POWER_STATE:
419-
if (*((uint32_t *)context) == DEVICE_PM_ACTIVE_STATE) {
418+
case PM_DEVICE_SET_POWER_STATE:
419+
if (*((uint32_t *)context) == PM_DEVICE_ACTIVE_STATE) {
420420
st7789v_exit_sleep(data);
421-
data->pm_state = DEVICE_PM_ACTIVE_STATE;
421+
data->pm_state = PM_DEVICE_ACTIVE_STATE;
422422
ret = 0;
423423
} else {
424424
st7789v_enter_sleep(data);
425-
data->pm_state = DEVICE_PM_LOW_POWER_STATE;
425+
data->pm_state = PM_DEVICE_LOW_POWER_STATE;
426426
ret = 0;
427427
}
428428
break;
429-
case DEVICE_PM_GET_POWER_STATE:
429+
case PM_DEVICE_GET_POWER_STATE:
430430
*((uint32_t *)context) = data->pm_state;
431431
break;
432432
default:

drivers/entropy/entropy_cc13xx_cc26xx.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -272,16 +272,16 @@ static int entropy_cc13xx_cc26xx_set_power_state(const struct device *dev,
272272
struct entropy_cc13xx_cc26xx_data *data = get_dev_data(dev);
273273
int ret = 0;
274274

275-
if ((new_state == DEVICE_PM_ACTIVE_STATE) &&
275+
if ((new_state == PM_DEVICE_ACTIVE_STATE) &&
276276
(new_state != data->pm_state)) {
277277
Power_setDependency(PowerCC26XX_PERIPH_TRNG);
278278
start_trng(data);
279279
} else {
280-
__ASSERT_NO_MSG(new_state == DEVICE_PM_LOW_POWER_STATE ||
281-
new_state == DEVICE_PM_SUSPEND_STATE ||
282-
new_state == DEVICE_PM_OFF_STATE);
280+
__ASSERT_NO_MSG(new_state == PM_DEVICE_LOW_POWER_STATE ||
281+
new_state == PM_DEVICE_SUSPEND_STATE ||
282+
new_state == PM_DEVICE_OFF_STATE);
283283

284-
if (data->pm_state == DEVICE_PM_ACTIVE_STATE) {
284+
if (data->pm_state == PM_DEVICE_ACTIVE_STATE) {
285285
stop_trng(data);
286286
Power_releaseDependency(PowerCC26XX_PERIPH_TRNG);
287287
}
@@ -299,15 +299,15 @@ static int entropy_cc13xx_cc26xx_pm_control(const struct device *dev,
299299
struct entropy_cc13xx_cc26xx_data *data = get_dev_data(dev);
300300
int ret = 0;
301301

302-
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) {
302+
if (ctrl_command == PM_DEVICE_SET_POWER_STATE) {
303303
uint32_t new_state = *((const uint32_t *)context);
304304

305305
if (new_state != data->pm_state) {
306306
ret = entropy_cc13xx_cc26xx_set_power_state(dev,
307307
new_state);
308308
}
309309
} else {
310-
__ASSERT_NO_MSG(ctrl_command == DEVICE_PM_GET_POWER_STATE);
310+
__ASSERT_NO_MSG(ctrl_command == PM_DEVICE_GET_POWER_STATE);
311311
*((uint32_t *)context) = data->pm_state;
312312
}
313313

@@ -324,7 +324,7 @@ static int entropy_cc13xx_cc26xx_init(const struct device *dev)
324324
struct entropy_cc13xx_cc26xx_data *data = get_dev_data(dev);
325325

326326
#ifdef CONFIG_PM_DEVICE
327-
get_dev_data(dev)->pm_state = DEVICE_PM_ACTIVE_STATE;
327+
get_dev_data(dev)->pm_state = PM_DEVICE_ACTIVE_STATE;
328328
#endif
329329

330330
/* Initialize driver data */

drivers/ethernet/eth_mcux.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ static int eth_mcux_device_pm_control(const struct device *dev,
198198
goto out;
199199
}
200200

201-
if (command == DEVICE_PM_SET_POWER_STATE) {
202-
if (*(uint32_t *)context == DEVICE_PM_SUSPEND_STATE) {
201+
if (command == PM_DEVICE_SET_POWER_STATE) {
202+
if (*(uint32_t *)context == PM_DEVICE_SUSPEND_STATE) {
203203
LOG_DBG("Suspending");
204204

205205
ret = net_if_suspend(eth_ctx->iface);
@@ -214,7 +214,7 @@ static int eth_mcux_device_pm_control(const struct device *dev,
214214
ENET_Deinit(eth_ctx->base);
215215
clock_control_off(eth_ctx->clock_dev,
216216
(clock_control_subsys_t)eth_ctx->clock);
217-
} else if (*(uint32_t *)context == DEVICE_PM_ACTIVE_STATE) {
217+
} else if (*(uint32_t *)context == PM_DEVICE_ACTIVE_STATE) {
218218
LOG_DBG("Resuming");
219219

220220
clock_control_on(eth_ctx->clock_dev,

drivers/flash/spi_flash_at45.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -576,21 +576,21 @@ static int spi_flash_at45_pm_control(const struct device *dev,
576576
const struct spi_flash_at45_config *dev_config = get_dev_config(dev);
577577
int err = 0;
578578

579-
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) {
579+
if (ctrl_command == PM_DEVICE_SET_POWER_STATE) {
580580
uint32_t new_state = *((const uint32_t *)context);
581581

582582
if (new_state != dev_data->pm_state) {
583583
switch (new_state) {
584-
case DEVICE_PM_ACTIVE_STATE:
584+
case PM_DEVICE_ACTIVE_STATE:
585585
acquire(dev);
586586
power_down_op(dev, CMD_EXIT_DPD,
587587
dev_config->t_exit_dpd);
588588
release(dev);
589589
break;
590590

591-
case DEVICE_PM_LOW_POWER_STATE:
592-
case DEVICE_PM_SUSPEND_STATE:
593-
case DEVICE_PM_OFF_STATE:
591+
case PM_DEVICE_LOW_POWER_STATE:
592+
case PM_DEVICE_SUSPEND_STATE:
593+
case PM_DEVICE_OFF_STATE:
594594
acquire(dev);
595595
power_down_op(dev,
596596
dev_config->use_udpd ? CMD_ENTER_UDPD
@@ -606,7 +606,7 @@ static int spi_flash_at45_pm_control(const struct device *dev,
606606
dev_data->pm_state = new_state;
607607
}
608608
} else {
609-
__ASSERT_NO_MSG(ctrl_command == DEVICE_PM_GET_POWER_STATE);
609+
__ASSERT_NO_MSG(ctrl_command == PM_DEVICE_GET_POWER_STATE);
610610
*((uint32_t *)context) = dev_data->pm_state;
611611
}
612612

@@ -647,7 +647,7 @@ static const struct flash_driver_api spi_flash_at45_api = {
647647
static struct spi_flash_at45_data inst_##idx##_data = { \
648648
.lock = Z_SEM_INITIALIZER(inst_##idx##_data.lock, 1, 1), \
649649
IF_ENABLED(CONFIG_PM_DEVICE, ( \
650-
.pm_state = DEVICE_PM_ACTIVE_STATE)) \
650+
.pm_state = PM_DEVICE_ACTIVE_STATE)) \
651651
}; \
652652
static const struct spi_flash_at45_config inst_##idx##_config = { \
653653
.spi_bus = DT_INST_BUS_LABEL(idx), \

drivers/flash/spi_nor.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ LOG_MODULE_REGISTER(spi_nor, CONFIG_FLASH_LOG_LEVEL);
3737
* Kconfig option.
3838
*
3939
* When mapped to the Zephyr Device Power Management states:
40-
* * DEVICE_PM_ACTIVE_STATE covers both active and standby modes;
41-
* * DEVICE_PM_LOW_POWER_STATE, DEVICE_PM_SUSPEND_STATE, and
42-
* DEVICE_PM_OFF_STATE all correspond to deep-power-down mode.
40+
* * PM_DEVICE_ACTIVE_STATE covers both active and standby modes;
41+
* * PM_DEVICE_LOW_POWER_STATE, PM_DEVICE_SUSPEND_STATE, and
42+
* PM_DEVICE_OFF_STATE all correspond to deep-power-down mode.
4343
*/
4444

4545
#define SPI_NOR_MAX_ADDR_WIDTH 4

drivers/gpio/gpio_dw.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -443,15 +443,15 @@ static uint32_t gpio_dw_get_power_state(const struct device *port)
443443
static inline int gpio_dw_suspend_port(const struct device *port)
444444
{
445445
gpio_dw_clock_off(port);
446-
gpio_dw_set_power_state(port, DEVICE_PM_SUSPEND_STATE);
446+
gpio_dw_set_power_state(port, PM_DEVICE_SUSPEND_STATE);
447447

448448
return 0;
449449
}
450450

451451
static inline int gpio_dw_resume_from_suspend_port(const struct device *port)
452452
{
453453
gpio_dw_clock_on(port);
454-
gpio_dw_set_power_state(port, DEVICE_PM_ACTIVE_STATE);
454+
gpio_dw_set_power_state(port, PM_DEVICE_ACTIVE_STATE);
455455
return 0;
456456
}
457457

@@ -465,13 +465,13 @@ static int gpio_dw_device_ctrl(const struct device *port,
465465
{
466466
int ret = 0;
467467

468-
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) {
469-
if (*((uint32_t *)context) == DEVICE_PM_SUSPEND_STATE) {
468+
if (ctrl_command == PM_DEVICE_SET_POWER_STATE) {
469+
if (*((uint32_t *)context) == PM_DEVICE_SUSPEND_STATE) {
470470
ret = gpio_dw_suspend_port(port);
471-
} else if (*((uint32_t *)context) == DEVICE_PM_ACTIVE_STATE) {
471+
} else if (*((uint32_t *)context) == PM_DEVICE_ACTIVE_STATE) {
472472
ret = gpio_dw_resume_from_suspend_port(port);
473473
}
474-
} else if (ctrl_command == DEVICE_PM_GET_POWER_STATE) {
474+
} else if (ctrl_command == PM_DEVICE_GET_POWER_STATE) {
475475
*((uint32_t *)context) = gpio_dw_get_power_state(port);
476476
}
477477

@@ -544,7 +544,7 @@ static int gpio_dw_initialize(const struct device *port)
544544
config->config_func(port);
545545
}
546546

547-
gpio_dw_set_power_state(port, DEVICE_PM_ACTIVE_STATE);
547+
gpio_dw_set_power_state(port, PM_DEVICE_ACTIVE_STATE);
548548

549549
return 0;
550550
}

drivers/i2c/i2c_cc13xx_cc26xx.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ static int i2c_cc13xx_cc26xx_set_power_state(const struct device *dev,
333333
{
334334
int ret = 0;
335335

336-
if ((new_state == DEVICE_PM_ACTIVE_STATE) &&
336+
if ((new_state == PM_DEVICE_ACTIVE_STATE) &&
337337
(new_state != get_dev_data(dev)->pm_state)) {
338338
Power_setDependency(PowerCC26XX_PERIPH_I2C0);
339339
IOCPinTypeI2c(get_dev_config(dev)->base,
@@ -346,11 +346,11 @@ static int i2c_cc13xx_cc26xx_set_power_state(const struct device *dev,
346346
get_dev_data(dev)->pm_state = new_state;
347347
}
348348
} else {
349-
__ASSERT_NO_MSG(new_state == DEVICE_PM_LOW_POWER_STATE ||
350-
new_state == DEVICE_PM_SUSPEND_STATE ||
351-
new_state == DEVICE_PM_OFF_STATE);
349+
__ASSERT_NO_MSG(new_state == PM_DEVICE_LOW_POWER_STATE ||
350+
new_state == PM_DEVICE_SUSPEND_STATE ||
351+
new_state == PM_DEVICE_OFF_STATE);
352352

353-
if (get_dev_data(dev)->pm_state == DEVICE_PM_ACTIVE_STATE) {
353+
if (get_dev_data(dev)->pm_state == PM_DEVICE_ACTIVE_STATE) {
354354
I2CMasterIntDisable(get_dev_config(dev)->base);
355355
I2CMasterDisable(get_dev_config(dev)->base);
356356
/* Reset pin type to default GPIO configuration */
@@ -373,15 +373,15 @@ static int i2c_cc13xx_cc26xx_pm_control(const struct device *dev,
373373
{
374374
int ret = 0;
375375

376-
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) {
376+
if (ctrl_command == PM_DEVICE_SET_POWER_STATE) {
377377
uint32_t new_state = *((const uint32_t *)context);
378378

379379
if (new_state != get_dev_data(dev)->pm_state) {
380380
ret = i2c_cc13xx_cc26xx_set_power_state(dev,
381381
new_state);
382382
}
383383
} else {
384-
__ASSERT_NO_MSG(ctrl_command == DEVICE_PM_GET_POWER_STATE);
384+
__ASSERT_NO_MSG(ctrl_command == PM_DEVICE_GET_POWER_STATE);
385385
*((uint32_t *)context) = get_dev_data(dev)->pm_state;
386386
}
387387

@@ -399,7 +399,7 @@ static int i2c_cc13xx_cc26xx_init(const struct device *dev)
399399
int err;
400400

401401
#ifdef CONFIG_PM_DEVICE
402-
get_dev_data(dev)->pm_state = DEVICE_PM_ACTIVE_STATE;
402+
get_dev_data(dev)->pm_state = PM_DEVICE_ACTIVE_STATE;
403403
#endif
404404

405405
#ifdef CONFIG_PM

drivers/i2c/i2c_nrfx_twi.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ static int init_twi(const struct device *dev)
206206
return -EBUSY;
207207
}
208208
#ifdef CONFIG_PM_DEVICE
209-
get_dev_data(dev)->pm_state = DEVICE_PM_ACTIVE_STATE;
209+
get_dev_data(dev)->pm_state = PM_DEVICE_ACTIVE_STATE;
210210
#endif
211211

212212
return 0;
@@ -220,12 +220,12 @@ static int twi_nrfx_pm_control(const struct device *dev,
220220
int ret = 0;
221221
uint32_t pm_current_state = get_dev_data(dev)->pm_state;
222222

223-
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) {
223+
if (ctrl_command == PM_DEVICE_SET_POWER_STATE) {
224224
uint32_t new_state = *((const uint32_t *)context);
225225

226226
if (new_state != pm_current_state) {
227227
switch (new_state) {
228-
case DEVICE_PM_ACTIVE_STATE:
228+
case PM_DEVICE_ACTIVE_STATE:
229229
init_twi(dev);
230230
if (get_dev_data(dev)->dev_config) {
231231
i2c_nrfx_twi_configure(
@@ -234,10 +234,10 @@ static int twi_nrfx_pm_control(const struct device *dev,
234234
}
235235
break;
236236

237-
case DEVICE_PM_LOW_POWER_STATE:
238-
case DEVICE_PM_SUSPEND_STATE:
239-
case DEVICE_PM_OFF_STATE:
240-
if (pm_current_state == DEVICE_PM_ACTIVE_STATE) {
237+
case PM_DEVICE_LOW_POWER_STATE:
238+
case PM_DEVICE_SUSPEND_STATE:
239+
case PM_DEVICE_OFF_STATE:
240+
if (pm_current_state == PM_DEVICE_ACTIVE_STATE) {
241241
nrfx_twi_uninit(&get_dev_config(dev)->twi);
242242
}
243243
break;
@@ -250,7 +250,7 @@ static int twi_nrfx_pm_control(const struct device *dev,
250250
}
251251
}
252252
} else {
253-
__ASSERT_NO_MSG(ctrl_command == DEVICE_PM_GET_POWER_STATE);
253+
__ASSERT_NO_MSG(ctrl_command == PM_DEVICE_GET_POWER_STATE);
254254
*((uint32_t *)context) = get_dev_data(dev)->pm_state;
255255
}
256256

0 commit comments

Comments
 (0)