Skip to content

Commit 7ccc1a4

Browse files
gmarullnashif
authored andcommitted
pm: use actions for device PM control
Instead of passing target states, use actions for device PM control. Actions represent better the meaning of the callback argument. Furthermore, they are more future proof as they can be suitable for other PM actions that have no direct mapping to a state. If we compare with Linux, we could have a multi-stage suspend/resume. Such scenario would not have a good mapping when using target states. Signed-off-by: Gerard Marull-Paretas <[email protected]>
1 parent 8be0472 commit 7ccc1a4

File tree

40 files changed

+176
-145
lines changed

40 files changed

+176
-145
lines changed

drivers/display/display_st7735r.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -495,16 +495,16 @@ static int st7735r_init(const struct device *dev)
495495

496496
#ifdef CONFIG_PM_DEVICE
497497
static int st7735r_pm_control(const struct device *dev,
498-
enum pm_device_state state)
498+
enum pm_device_action action)
499499
{
500500
int ret = 0;
501501
struct st7735r_data *data = (struct st7735r_data *)dev->data;
502502

503-
switch (state) {
504-
case PM_DEVICE_STATE_ACTIVE:
503+
switch (action) {
504+
case PM_DEVICE_ACTION_RESUME:
505505
ret = st7735r_exit_sleep(data);
506506
break;
507-
case PM_DEVICE_STATE_SUSPENDED:
507+
case PM_DEVICE_ACTION_SUSPEND:
508508
ret = st7735r_transmit(data, ST7735R_CMD_SLEEP_IN, NULL, 0);
509509
break;
510510
default:

drivers/display/display_st7789v.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -397,16 +397,16 @@ static int st7789v_init(const struct device *dev)
397397

398398
#ifdef CONFIG_PM_DEVICE
399399
static int st7789v_pm_control(const struct device *dev,
400-
enum pm_device_state state)
400+
enum pm_device_action action)
401401
{
402402
struct st7789v_data *data = (struct st7789v_data *)dev->data;
403403
int ret = 0;
404404

405-
switch (state) {
406-
case PM_DEVICE_STATE_ACTIVE:
405+
switch (action) {
406+
case PM_DEVICE_ACTION_RESUME:
407407
st7789v_exit_sleep(data);
408408
break;
409-
case PM_DEVICE_STATE_SUSPENDED:
409+
case PM_DEVICE_ACTION_SUSPEND:
410410
ret = st7789v_transmit(data, ST7789V_CMD_SLEEP_IN, NULL, 0);
411411
break;
412412
default:

drivers/entropy/entropy_cc13xx_cc26xx.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,16 +265,16 @@ static int post_notify_fxn(unsigned int eventType, uintptr_t eventArg,
265265

266266
#ifdef CONFIG_PM_DEVICE
267267
static int entropy_cc13xx_cc26xx_pm_control(const struct device *dev,
268-
enum pm_device_state state)
268+
enum pm_device_action action)
269269
{
270270
struct entropy_cc13xx_cc26xx_data *data = get_dev_data(dev);
271271

272-
switch (state) {
273-
case PM_DEVICE_STATE_ACTIVE:
272+
switch (action) {
273+
case PM_DEVICE_ACTION_RESUME:
274274
Power_setDependency(PowerCC26XX_PERIPH_TRNG);
275275
start_trng(data);
276276
break;
277-
case PM_DEVICE_STATE_SUSPENDED:
277+
case PM_DEVICE_ACTION_SUSPEND:
278278
stop_trng(data);
279279
Power_releaseDependency(PowerCC26XX_PERIPH_TRNG);
280280
break;

drivers/ethernet/eth_mcux.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ static void eth_mcux_phy_enter_reset(struct eth_context *context);
185185
void eth_mcux_phy_stop(struct eth_context *context);
186186

187187
static int eth_mcux_device_pm_control(const struct device *dev,
188-
enum pm_device_state state)
188+
enum pm_device_action action)
189189
{
190190
struct eth_context *eth_ctx = (struct eth_context *)dev->data;
191191
int ret = 0;
@@ -197,8 +197,8 @@ static int eth_mcux_device_pm_control(const struct device *dev,
197197
goto out;
198198
}
199199

200-
switch (state) {
201-
case PM_DEVICE_STATE_SUSPENDED:
200+
switch (action) {
201+
case PM_DEVICE_ACTION_SUSPEND:
202202
LOG_DBG("Suspending");
203203

204204
ret = net_if_suspend(eth_ctx->iface);
@@ -214,7 +214,7 @@ static int eth_mcux_device_pm_control(const struct device *dev,
214214
clock_control_off(eth_ctx->clock_dev,
215215
(clock_control_subsys_t)eth_ctx->clock);
216216
break;
217-
case PM_DEVICE_STATE_ACTIVE:
217+
case PM_DEVICE_ACTION_RESUME:
218218
LOG_DBG("Resuming");
219219

220220
clock_control_on(eth_ctx->clock_dev,

drivers/flash/spi_flash_at45.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -625,18 +625,18 @@ static int spi_flash_at45_init(const struct device *dev)
625625

626626
#if IS_ENABLED(CONFIG_PM_DEVICE)
627627
static int spi_flash_at45_pm_control(const struct device *dev,
628-
enum pm_device_state state)
628+
enum pm_device_action action)
629629
{
630630
const struct spi_flash_at45_config *dev_config = get_dev_config(dev);
631631

632-
switch (state) {
633-
case PM_DEVICE_STATE_ACTIVE:
632+
switch (action) {
633+
case PM_DEVICE_ACTION_RESUME:
634634
acquire(dev);
635635
power_down_op(dev, CMD_EXIT_DPD, dev_config->t_exit_dpd);
636636
release(dev);
637637
break;
638638

639-
case PM_DEVICE_STATE_SUSPENDED:
639+
case PM_DEVICE_ACTION_SUSPEND:
640640
acquire(dev);
641641
power_down_op(dev,
642642
dev_config->use_udpd ? CMD_ENTER_UDPD : CMD_ENTER_DPD,

drivers/gpio/gpio_dw.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,13 +430,13 @@ static inline int gpio_dw_manage_callback(const struct device *port,
430430
* the *context may include IN data or/and OUT data
431431
*/
432432
static int gpio_dw_device_ctrl(const struct device *dev,
433-
enum pm_device_state state)
433+
enum pm_device_action action)
434434
{
435-
switch (state) {
436-
case PM_DEVICE_STATE_SUSPENDED:
435+
switch (action) {
436+
case PM_DEVICE_ACTION_SUSPEND:
437437
gpio_dw_clock_off(dev);
438438
break;
439-
case PM_DEVICE_STATE_ACTIVE:
439+
case PM_DEVICE_ACTION_RESUME:
440440
gpio_dw_clock_on(dev);
441441
break;
442442
default:

drivers/gpio/gpio_stm32.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -575,12 +575,12 @@ static const struct gpio_driver_api gpio_stm32_driver = {
575575

576576
#ifdef CONFIG_PM_DEVICE
577577
static int gpio_stm32_pm_device_ctrl(const struct device *dev,
578-
enum pm_device_state state)
578+
enum pm_device_action action)
579579
{
580-
switch (state) {
581-
case PM_DEVICE_STATE_ACTIVE:
580+
switch (action) {
581+
case PM_DEVICE_ACTION_RESUME:
582582
return gpio_stm32_clock_request(dev, true);
583-
case PM_DEVICE_STATE_SUSPENDED:
583+
case PM_DEVICE_ACTION_SUSPEND:
584584
return gpio_stm32_clock_request(dev, false);
585585
default:
586586
return -ENOTSUP;

drivers/i2c/i2c_cc13xx_cc26xx.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,12 +327,12 @@ static int postNotifyFxn(unsigned int eventType, uintptr_t eventArg,
327327

328328
#ifdef CONFIG_PM_DEVICE
329329
static int i2c_cc13xx_cc26xx_pm_control(const struct device *dev,
330-
enum pm_device_state state)
330+
enum pm_device_action action)
331331
{
332332
int ret = 0;
333333

334-
switch (state) {
335-
case PM_DEVICE_STATE_ACTIVE:
334+
switch (action) {
335+
case PM_DEVICE_ACTION_RESUME:
336336
Power_setDependency(PowerCC26XX_PERIPH_I2C0);
337337
IOCPinTypeI2c(get_dev_config(dev)->base,
338338
get_dev_config(dev)->sda_pin,
@@ -343,7 +343,7 @@ static int i2c_cc13xx_cc26xx_pm_control(const struct device *dev,
343343
I2CMasterIntEnable(get_dev_config(dev)->base);
344344
}
345345
break;
346-
case PM_DEVICE_STATE_SUSPENDED:
346+
case PM_DEVICE_ACTION_SUSPEND:
347347
I2CMasterIntDisable(get_dev_config(dev)->base);
348348
I2CMasterDisable(get_dev_config(dev)->base);
349349
/* Reset pin type to default GPIO configuration */

drivers/i2c/i2c_nrfx_twi.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,20 +217,20 @@ static int init_twi(const struct device *dev)
217217

218218
#ifdef CONFIG_PM_DEVICE
219219
static int twi_nrfx_pm_control(const struct device *dev,
220-
enum pm_device_state state)
220+
enum pm_device_action action)
221221
{
222222
int ret = 0;
223223

224-
switch (state) {
225-
case PM_DEVICE_STATE_ACTIVE:
224+
switch (action) {
225+
case PM_DEVICE_ACTION_RESUME:
226226
init_twi(dev);
227227
if (get_dev_data(dev)->dev_config) {
228228
i2c_nrfx_twi_configure(dev,
229229
get_dev_data(dev)->dev_config);
230230
}
231231
break;
232232

233-
case PM_DEVICE_STATE_SUSPENDED:
233+
case PM_DEVICE_ACTION_SUSPEND:
234234
nrfx_twi_uninit(&get_dev_config(dev)->twi);
235235
break;
236236

drivers/i2c/i2c_nrfx_twim.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,20 +255,20 @@ static int init_twim(const struct device *dev)
255255

256256
#ifdef CONFIG_PM_DEVICE
257257
static int twim_nrfx_pm_control(const struct device *dev,
258-
enum pm_device_state state)
258+
enum pm_device_action action)
259259
{
260260
int ret = 0;
261261

262-
switch (state) {
263-
case PM_DEVICE_STATE_ACTIVE:
262+
switch (action) {
263+
case PM_DEVICE_ACTION_RESUME:
264264
init_twim(dev);
265265
if (get_dev_data(dev)->dev_config) {
266266
i2c_nrfx_twim_configure(dev,
267267
get_dev_data(dev)->dev_config);
268268
}
269269
break;
270270

271-
case PM_DEVICE_STATE_SUSPENDED:
271+
case PM_DEVICE_ACTION_SUSPEND:
272272
nrfx_twim_uninit(&get_dev_config(dev)->twim);
273273
break;
274274

0 commit comments

Comments
 (0)