pm: device: remove pointer usage for state

Since the state is no longer modified by the device PM callback, just
use the state value.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
Gerard Marull-Paretas 2021-06-09 13:47:18 +02:00 committed by Anas Nashif
commit 11eef4d8c8
41 changed files with 100 additions and 100 deletions

View file

@ -500,12 +500,12 @@ static int st7735r_enter_sleep(struct st7735r_data *data)
} }
static int st7735r_pm_control(const struct device *dev, static int st7735r_pm_control(const struct device *dev,
enum pm_device_state *state) enum pm_device_state state)
{ {
int ret = 0; int ret = 0;
struct st7735r_data *data = (struct st7735r_data *)dev->data; struct st7735r_data *data = (struct st7735r_data *)dev->data;
if (*state == PM_DEVICE_STATE_ACTIVE) { if (state == PM_DEVICE_STATE_ACTIVE) {
ret = st7735r_exit_sleep(data); ret = st7735r_exit_sleep(data);
if (ret < 0) { if (ret < 0) {
return ret; return ret;

View file

@ -402,11 +402,11 @@ static void st7789v_enter_sleep(struct st7789v_data *data)
} }
static int st7789v_pm_control(const struct device *dev, static int st7789v_pm_control(const struct device *dev,
enum pm_device_state *state) enum pm_device_state state)
{ {
struct st7789v_data *data = (struct st7789v_data *)dev->data; struct st7789v_data *data = (struct st7789v_data *)dev->data;
if (*state == PM_DEVICE_STATE_ACTIVE) { if (state == PM_DEVICE_STATE_ACTIVE) {
st7789v_exit_sleep(data); st7789v_exit_sleep(data);
} else { } else {
st7789v_enter_sleep(data); st7789v_enter_sleep(data);

View file

@ -291,14 +291,14 @@ static int entropy_cc13xx_cc26xx_set_power_state(const struct device *dev,
} }
static int entropy_cc13xx_cc26xx_pm_control(const struct device *dev, static int entropy_cc13xx_cc26xx_pm_control(const struct device *dev,
enum pm_device_state *state) enum pm_device_state state)
{ {
int ret = 0; int ret = 0;
enum pm_device_state curr_state; enum pm_device_state curr_state;
(void)pm_device_state_get(dev, &curr_state); (void)pm_device_state_get(dev, &curr_state);
if (*state != curr_state) { if (state != curr_state) {
ret = entropy_cc13xx_cc26xx_set_power_state(dev, *state); ret = entropy_cc13xx_cc26xx_set_power_state(dev, state);
} }
return ret; return ret;

View file

@ -185,7 +185,7 @@ static void eth_mcux_phy_enter_reset(struct eth_context *context);
void eth_mcux_phy_stop(struct eth_context *context); void eth_mcux_phy_stop(struct eth_context *context);
static int eth_mcux_device_pm_control(const struct device *dev, static int eth_mcux_device_pm_control(const struct device *dev,
enum pm_device_state *state) enum pm_device_state state)
{ {
struct eth_context *eth_ctx = (struct eth_context *)dev->data; struct eth_context *eth_ctx = (struct eth_context *)dev->data;
int ret = 0; int ret = 0;
@ -197,7 +197,7 @@ static int eth_mcux_device_pm_control(const struct device *dev,
goto out; goto out;
} }
if (*state == PM_DEVICE_STATE_SUSPEND) { if (state == PM_DEVICE_STATE_SUSPEND) {
LOG_DBG("Suspending"); LOG_DBG("Suspending");
ret = net_if_suspend(eth_ctx->iface); ret = net_if_suspend(eth_ctx->iface);
@ -212,7 +212,7 @@ static int eth_mcux_device_pm_control(const struct device *dev,
ENET_Deinit(eth_ctx->base); ENET_Deinit(eth_ctx->base);
clock_control_off(eth_ctx->clock_dev, clock_control_off(eth_ctx->clock_dev,
(clock_control_subsys_t)eth_ctx->clock); (clock_control_subsys_t)eth_ctx->clock);
} else if (*state == PM_DEVICE_STATE_ACTIVE) { } else if (state == PM_DEVICE_STATE_ACTIVE) {
LOG_DBG("Resuming"); LOG_DBG("Resuming");
clock_control_on(eth_ctx->clock_dev, clock_control_on(eth_ctx->clock_dev,

View file

@ -625,15 +625,15 @@ static int spi_flash_at45_init(const struct device *dev)
#if IS_ENABLED(CONFIG_PM_DEVICE) #if IS_ENABLED(CONFIG_PM_DEVICE)
static int spi_flash_at45_pm_control(const struct device *dev, static int spi_flash_at45_pm_control(const struct device *dev,
enum pm_device_state *state) enum pm_device_state state)
{ {
const struct spi_flash_at45_config *dev_config = get_dev_config(dev); const struct spi_flash_at45_config *dev_config = get_dev_config(dev);
int err = 0; int err = 0;
enum pm_device_state curr_state; enum pm_device_state curr_state;
(void)pm_device_state_get(dev, &curr_state); (void)pm_device_state_get(dev, &curr_state);
if (*state != curr_state) { if (state != curr_state) {
switch (*state) { switch (state) {
case PM_DEVICE_STATE_ACTIVE: case PM_DEVICE_STATE_ACTIVE:
acquire(dev); acquire(dev);
power_down_op(dev, CMD_EXIT_DPD, power_down_op(dev, CMD_EXIT_DPD,

View file

@ -442,13 +442,13 @@ static inline int gpio_dw_resume_from_suspend_port(const struct device *port)
* the *context may include IN data or/and OUT data * the *context may include IN data or/and OUT data
*/ */
static int gpio_dw_device_ctrl(const struct device *port, static int gpio_dw_device_ctrl(const struct device *port,
enum pm_device_state *state) enum pm_device_state state)
{ {
int ret = 0; int ret = 0;
if (*state == PM_DEVICE_STATE_SUSPEND) { if (state == PM_DEVICE_STATE_SUSPEND) {
ret = gpio_dw_suspend_port(port); ret = gpio_dw_suspend_port(port);
} else if (*state == PM_DEVICE_STATE_ACTIVE) { } else if (state == PM_DEVICE_STATE_ACTIVE) {
ret = gpio_dw_resume_from_suspend_port(port); ret = gpio_dw_resume_from_suspend_port(port);
} }

View file

@ -595,14 +595,14 @@ static int gpio_stm32_set_power_state(const struct device *dev,
} }
static int gpio_stm32_pm_device_ctrl(const struct device *dev, static int gpio_stm32_pm_device_ctrl(const struct device *dev,
enum pm_device_state *state) enum pm_device_state state)
{ {
int ret = 0; int ret = 0;
enum pm_device_state curr_state; enum pm_device_state curr_state;
(void)pm_device_state_get(dev, &curr_state); (void)pm_device_state_get(dev, &curr_state);
if (*state != curr_state) { if (state != curr_state) {
ret = gpio_stm32_set_power_state(dev, *state); ret = gpio_stm32_set_power_state(dev, state);
} }
return ret; return ret;

View file

@ -365,13 +365,13 @@ static int i2c_cc13xx_cc26xx_set_power_state(const struct device *dev,
} }
static int i2c_cc13xx_cc26xx_pm_control(const struct device *dev, static int i2c_cc13xx_cc26xx_pm_control(const struct device *dev,
enum pm_device_state *state) enum pm_device_state state)
{ {
int ret = 0; int ret = 0;
enum pm_device_state curr_state; enum pm_device_state curr_state;
(void)pm_device_state_get(dev, &curr_state); (void)pm_device_state_get(dev, &curr_state);
if (*state != curr_state) { if (state != curr_state) {
ret = i2c_cc13xx_cc26xx_set_power_state(dev, ret = i2c_cc13xx_cc26xx_set_power_state(dev,
new_state); new_state);
} }

View file

@ -217,14 +217,14 @@ static int init_twi(const struct device *dev)
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
static int twi_nrfx_pm_control(const struct device *dev, static int twi_nrfx_pm_control(const struct device *dev,
enum pm_device_state *state) enum pm_device_state state)
{ {
int ret = 0; int ret = 0;
enum pm_device_state curr_state; enum pm_device_state curr_state;
(void)pm_device_state_get(dev, &curr_state); (void)pm_device_state_get(dev, &curr_state);
if (*state != curr_state) { if (state != curr_state) {
switch (*state) { switch (state) {
case PM_DEVICE_STATE_ACTIVE: case PM_DEVICE_STATE_ACTIVE:
init_twi(dev); init_twi(dev);
if (get_dev_data(dev)->dev_config) { if (get_dev_data(dev)->dev_config) {

View file

@ -255,14 +255,14 @@ static int init_twim(const struct device *dev)
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
static int twim_nrfx_pm_control(const struct device *dev, static int twim_nrfx_pm_control(const struct device *dev,
enum pm_device_state *state) enum pm_device_state state)
{ {
int ret = 0; int ret = 0;
enum pm_device_state curr_state; enum pm_device_state curr_state;
(void)pm_device_state_get(dev, &curr_state); (void)pm_device_state_get(dev, &curr_state);
if (*state != curr_state) { if (state != curr_state) {
switch (*state) { switch (state) {
case PM_DEVICE_STATE_ACTIVE: case PM_DEVICE_STATE_ACTIVE:
init_twim(dev); init_twim(dev);
if (get_dev_data(dev)->dev_config) { if (get_dev_data(dev)->dev_config) {

View file

@ -175,14 +175,14 @@ static int arc_v2_irq_unit_resume(const struct device *dev)
* @return operation result * @return operation result
*/ */
static int arc_v2_irq_unit_device_ctrl(const struct device *dev, static int arc_v2_irq_unit_device_ctrl(const struct device *dev,
enum pm_device_state *state) enum pm_device_state state)
{ {
int ret = 0; int ret = 0;
unsigned int key = arch_irq_lock(); unsigned int key = arch_irq_lock();
if (*state == PM_DEVICE_STATE_SUSPEND) { if (state == PM_DEVICE_STATE_SUSPEND) {
ret = arc_v2_irq_unit_suspend(dev); ret = arc_v2_irq_unit_suspend(dev);
} else if (*state == PM_DEVICE_STATE_ACTIVE) { } else if (state == PM_DEVICE_STATE_ACTIVE) {
ret = arc_v2_irq_unit_resume(dev); ret = arc_v2_irq_unit_resume(dev);
} }

View file

@ -310,13 +310,13 @@ int ioapic_resume_from_suspend(const struct device *port)
*/ */
__pinned_func __pinned_func
static int ioapic_device_ctrl(const struct device *dev, static int ioapic_device_ctrl(const struct device *dev,
enum pm_device_state *state) enum pm_device_state state)
{ {
int ret = 0; int ret = 0;
enum pm_device_state curr_state; enum pm_device_state curr_state;
(void)pm_device_state_get(dev, &curr_state); (void)pm_device_state_get(dev, &curr_state);
switch (*state) { switch (state) {
case PM_DEVICE_STATE_LOW_POWER: case PM_DEVICE_STATE_LOW_POWER:
break; break;
case PM_DEVICE_STATE_ACTIVE: case PM_DEVICE_STATE_ACTIVE:

View file

@ -409,13 +409,13 @@ int loapic_resume(const struct device *port)
*/ */
__pinned_func __pinned_func
static int loapic_device_ctrl(const struct device *port, static int loapic_device_ctrl(const struct device *port,
enum pm_device_state *state) enum pm_device_state state)
{ {
int ret = 0; int ret = 0;
if (*state == PM_DEVICE_STATE_SUSPEND) { if (state == PM_DEVICE_STATE_SUSPEND) {
ret = loapic_suspend(port); ret = loapic_suspend(port);
} else if (*state == PM_DEVICE_STATE_ACTIVE) { } else if (state == PM_DEVICE_STATE_ACTIVE) {
ret = loapic_resume(port); ret = loapic_resume(port);
} }

View file

@ -143,9 +143,9 @@ static int led_pwm_pm_set_state(const struct device *dev,
} }
static int led_pwm_pm_control(const struct device *dev, static int led_pwm_pm_control(const struct device *dev,
enum pm_device_state *state) enum pm_device_state state)
{ {
return led_pwm_pm_set_state(dev, *state); return led_pwm_pm_set_state(dev, state);
} }
#endif /* CONFIG_PM_DEVICE */ #endif /* CONFIG_PM_DEVICE */

View file

@ -318,14 +318,14 @@ static int pwm_nrfx_set_power_state(enum pm_device_state new_state,
} }
static int pwm_nrfx_pm_control(const struct device *dev, static int pwm_nrfx_pm_control(const struct device *dev,
enum pm_device_state *state) enum pm_device_state state)
{ {
int err = 0; int err = 0;
enum pm_device_state curr_state; enum pm_device_state curr_state;
(void)pm_device_state_get(dev, &curr_state); (void)pm_device_state_get(dev, &curr_state);
if (*state != current_state) { if (state != current_state) {
err = pwm_nrfx_set_power_state(*state, current_state, dev); err = pwm_nrfx_set_power_state(state, current_state, dev);
} }
return err; return err;
@ -333,7 +333,7 @@ static int pwm_nrfx_pm_control(const struct device *dev,
#define PWM_NRFX_PM_CONTROL(idx) \ #define PWM_NRFX_PM_CONTROL(idx) \
static int pwm_##idx##_nrfx_pm_control(const struct device *dev, \ static int pwm_##idx##_nrfx_pm_control(const struct device *dev, \
enum pm_device_state *state) \ enum pm_device_state state) \
{ \ { \
return pwm_nrfx_pm_control(dev, state) \ return pwm_nrfx_pm_control(dev, state) \
} }

View file

@ -409,13 +409,13 @@ static int apds9960_init_interrupt(const struct device *dev)
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
static int apds9960_device_ctrl(const struct device *dev, static int apds9960_device_ctrl(const struct device *dev,
enum pm_device_state *state) enum pm_device_state state)
{ {
const struct apds9960_config *config = dev->config; const struct apds9960_config *config = dev->config;
struct apds9960_data *data = dev->data; struct apds9960_data *data = dev->data;
int ret = 0; int ret = 0;
if (*state == PM_DEVICE_STATE_ACTIVE) { if (state == PM_DEVICE_STATE_ACTIVE) {
if (i2c_reg_update_byte(data->i2c, config->i2c_address, if (i2c_reg_update_byte(data->i2c, config->i2c_address,
APDS9960_ENABLE_REG, APDS9960_ENABLE_REG,
APDS9960_ENABLE_PON, APDS9960_ENABLE_PON,

View file

@ -410,13 +410,13 @@ static int bme280_chip_init(const struct device *dev)
} }
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
int bme280_pm_ctrl(const struct device *dev, enum pm_device_state *state) int bme280_pm_ctrl(const struct device *dev, enum pm_device_state state)
{ {
int ret = 0; int ret = 0;
enum pm_device_state curr_state; enum pm_device_state curr_state;
pm_device_state_get(dev, &curr_state); pm_device_state_get(dev, &curr_state);
if (*state != curr_state) { if (state != curr_state) {
/* Switching from OFF to any */ /* Switching from OFF to any */
if (curr_state == PM_DEVICE_STATE_OFF) { if (curr_state == PM_DEVICE_STATE_OFF) {
@ -425,7 +425,7 @@ int bme280_pm_ctrl(const struct device *dev, enum pm_device_state *state)
ret = bme280_chip_init(dev); ret = bme280_chip_init(dev);
} }
/* Switching to OFF from any */ /* Switching to OFF from any */
else if (*state == PM_DEVICE_STATE_OFF) { else if (state == PM_DEVICE_STATE_OFF) {
/* Put the chip into sleep mode */ /* Put the chip into sleep mode */
ret = bme280_reg_write(dev, ret = bme280_reg_write(dev,

View file

@ -583,11 +583,11 @@ static int bmp388_set_power_state(const struct device *dev,
static int bmp388_device_ctrl( static int bmp388_device_ctrl(
const struct device *dev, const struct device *dev,
enum pm_device_state *state) enum pm_device_state state)
{ {
int ret = 0; int ret = 0;
ret = bmp388_set_power_state(dev, *state); ret = bmp388_set_power_state(dev, state);
return ret; return ret;
} }

View file

@ -732,17 +732,17 @@ static int bq274xx_exit_shutdown_mode(const struct device *dev)
} }
static int bq274xx_pm_control(const struct device *dev, static int bq274xx_pm_control(const struct device *dev,
enum pm_device_state *state) enum pm_device_state state)
{ {
int ret = 0; int ret = 0;
struct bq274xx_data *data = dev->data; struct bq274xx_data *data = dev->data;
if (*state == PM_DEVICE_STATE_OFF) { if (state == PM_DEVICE_STATE_OFF) {
ret = bq274xx_enter_shutdown_mode(data); ret = bq274xx_enter_shutdown_mode(data);
if (ret < 0) { if (ret < 0) {
LOG_ERR("Unable to enter off state"); LOG_ERR("Unable to enter off state");
} }
} else if (*state == PM_DEVICE_STATE_ACTIVE) { } else if (state == PM_DEVICE_STATE_ACTIVE) {
ret = bq274xx_exit_shutdown_mode(dev); ret = bq274xx_exit_shutdown_mode(dev);
if (ret < 0) { if (ret < 0) {
LOG_ERR("Unable to enter active state"); LOG_ERR("Unable to enter active state");

View file

@ -535,7 +535,7 @@ static int fdc2x1x_set_pm_state(const struct device *dev,
} }
static int fdc2x1x_device_pm_ctrl(const struct device *dev, static int fdc2x1x_device_pm_ctrl(const struct device *dev,
enum pm_device_state *state) enum pm_device_state state)
{ {
struct fdc2x1x_data *data = dev->data; struct fdc2x1x_data *data = dev->data;
int ret = 0; int ret = 0;
@ -543,12 +543,12 @@ static int fdc2x1x_device_pm_ctrl(const struct device *dev,
(void)pm_device_state_get(dev, &curr_state); (void)pm_device_state_get(dev, &curr_state);
if (*state != curr_state) { if (state != curr_state) {
switch (*state) { switch (state) {
case PM_DEVICE_STATE_ACTIVE: case PM_DEVICE_STATE_ACTIVE:
case PM_DEVICE_STATE_LOW_POWER: case PM_DEVICE_STATE_LOW_POWER:
case PM_DEVICE_STATE_OFF: case PM_DEVICE_STATE_OFF:
ret = fdc2x1x_set_pm_state(dev, *state); ret = fdc2x1x_set_pm_state(dev, state);
break; break;
default: default:
LOG_ERR("PM state not supported"); LOG_ERR("PM state not supported");

View file

@ -476,7 +476,7 @@ static int lis2mdl_set_power_state(struct lis2mdl_data *lis2mdl,
} }
static int lis2mdl_pm_control(const struct device *dev, static int lis2mdl_pm_control(const struct device *dev,
enum pm_device_state *state) enum pm_device_state state)
{ {
struct lis2mdl_data *lis2mdl = dev->data; struct lis2mdl_data *lis2mdl = dev->data;
const struct lis2mdl_config *const config = dev->config; const struct lis2mdl_config *const config = dev->config;
@ -484,8 +484,8 @@ static int lis2mdl_pm_control(const struct device *dev,
enum pm_device_state curr_state; enum pm_device_state curr_state;
(void)pm_device_state_get(dev, &curr_state); (void)pm_device_state_get(dev, &curr_state);
if (*state != curr_state) { if (state != curr_state) {
status = lis2mdl_set_power_state(lis2mdl, config, *state); status = lis2mdl_set_power_state(lis2mdl, config, state);
} }
return status; return status;

View file

@ -240,14 +240,14 @@ static int qdec_nrfx_pm_set_state(struct qdec_nrfx_data *data,
} }
static int qdec_nrfx_pm_control(const struct device *dev, static int qdec_nrfx_pm_control(const struct device *dev,
enum pm_device_state *state) enum pm_device_state state)
{ {
struct qdec_nrfx_data *data = &qdec_nrfx_data; struct qdec_nrfx_data *data = &qdec_nrfx_data;
int err; int err;
LOG_DBG(""); LOG_DBG("");
err = qdec_nrfx_pm_set_state(data, *state); err = qdec_nrfx_pm_set_state(data, state);
return err; return err;
} }

View file

@ -218,9 +218,9 @@ static int sgp40_set_power_state(const struct device *dev,
return 0; return 0;
} }
static int sgp40_pm_ctrl(const struct device *dev, enum pm_device_state *state) static int sgp40_pm_ctrl(const struct device *dev, enum pm_device_state state)
{ {
return sgp40_set_power_state(dev, *state); return sgp40_set_power_state(dev, state);
} }
#endif /* CONFIG_PM_DEVICE */ #endif /* CONFIG_PM_DEVICE */

View file

@ -219,7 +219,7 @@ static int vcnl4040_ambient_setup(const struct device *dev)
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
static int vcnl4040_device_ctrl(const struct device *dev, static int vcnl4040_device_ctrl(const struct device *dev,
enum pm_device_state *state) enum pm_device_state state)
{ {
int ret = 0; int ret = 0;
uint16_t ps_conf; uint16_t ps_conf;
@ -234,7 +234,7 @@ static int vcnl4040_device_ctrl(const struct device *dev,
if (ret < 0) if (ret < 0)
return ret; return ret;
#endif #endif
if (*state == PM_DEVICE_STATE_ACTIVE) { if (state == PM_DEVICE_STATE_ACTIVE) {
/* Clear proximity shutdown */ /* Clear proximity shutdown */
ps_conf &= ~VCNL4040_PS_SD_MASK; ps_conf &= ~VCNL4040_PS_SD_MASK;

View file

@ -441,14 +441,14 @@ static int uart_cc13xx_cc26xx_set_power_state(const struct device *dev,
} }
static int uart_cc13xx_cc26xx_pm_control(const struct device *dev, static int uart_cc13xx_cc26xx_pm_control(const struct device *dev,
enum pm_device_state *state) enum pm_device_state state)
{ {
int ret = 0; int ret = 0;
enum pm_device_state curr_state; enum pm_device_state curr_state;
(void)pm_device_state_get(dev, &curr_state); (void)pm_device_state_get(dev, &curr_state);
if (*state != curr_state) { if (state != curr_state) {
ret = uart_cc13xx_cc26xx_set_power_state(dev, *state); ret = uart_cc13xx_cc26xx_set_power_state(dev, state);
} }
return ret; return ret;

View file

@ -458,9 +458,9 @@ static inline int uart_npcx_set_power_state(const struct device *dev,
/* Implements the device power management control functionality */ /* Implements the device power management control functionality */
static int uart_npcx_pm_control(const struct device *dev, static int uart_npcx_pm_control(const struct device *dev,
enum pm_device_state *state) enum pm_device_state state)
{ {
return uart_npcx_set_power_state(dev, *state); return uart_npcx_set_power_state(dev, state);
} }
#endif /* CONFIG_PM_DEVICE */ #endif /* CONFIG_PM_DEVICE */

View file

@ -1159,13 +1159,13 @@ static void uart_nrfx_set_power_state(const struct device *dev,
} }
static int uart_nrfx_pm_control(const struct device *dev, static int uart_nrfx_pm_control(const struct device *dev,
enum pm_device_state *state) enum pm_device_state state)
{ {
enum pm_device_state current_state; enum pm_device_state current_state;
(void)pm_device_state_get(dev, &current_state); (void)pm_device_state_get(dev, &current_state);
if (*state != current_state) { if (state != current_state) {
uart_nrfx_set_power_state(dev, *state); uart_nrfx_set_power_state(dev, state);
} }
return 0; return 0;

View file

@ -1922,13 +1922,13 @@ static void uarte_nrfx_set_power_state(const struct device *dev,
} }
static int uarte_nrfx_pm_control(const struct device *dev, static int uarte_nrfx_pm_control(const struct device *dev,
enum pm_device_state *state) enum pm_device_state state)
{ {
enum pm_device_state curr_state; enum pm_device_state curr_state;
(void)pm_device_state_get(dev, &curr_state); (void)pm_device_state_get(dev, &curr_state);
if (*state != curr_state) { if (state != curr_state) {
uarte_nrfx_set_power_state(dev, *state); uarte_nrfx_set_power_state(dev, state);
} }
return 0; return 0;

View file

@ -1460,13 +1460,13 @@ static int uart_stm32_set_power_state(const struct device *dev,
* @return 0 * @return 0
*/ */
static int uart_stm32_pm_control(const struct device *dev, static int uart_stm32_pm_control(const struct device *dev,
enum pm_device_state *state) enum pm_device_state state)
{ {
enum pm_device_state curr_state; enum pm_device_state curr_state;
(void)pm_device_state_get(dev, &curr_state); (void)pm_device_state_get(dev, &curr_state);
if (*state != curr_state) { if (state != curr_state) {
uart_stm32_set_power_state(dev, *state); uart_stm32_set_power_state(dev, state);
} }
return 0; return 0;

View file

@ -248,14 +248,14 @@ static int spi_cc13xx_cc26xx_set_power_state(const struct device *dev,
} }
static int spi_cc13xx_cc26xx_pm_control(const struct device *dev, static int spi_cc13xx_cc26xx_pm_control(const struct device *dev,
enum pm_device_state *state) enum pm_device_state state)
{ {
int ret = 0; int ret = 0;
enum pm_device_state curr_state; enum pm_device_state curr_state;
(void)pm_device_state_get(dev, &curr_state); (void)pm_device_state_get(dev, &curr_state);
if (*state != curr_state) { if (state != curr_state) {
ret = spi_cc13xx_cc26xx_set_power_state(dev, *state); ret = spi_cc13xx_cc26xx_set_power_state(dev, state);
} }
return ret; return ret;

View file

@ -278,7 +278,7 @@ static int init_spi(const struct device *dev)
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
static int spi_nrfx_pm_control(const struct device *dev, static int spi_nrfx_pm_control(const struct device *dev,
enum pm_device_state *state) enum pm_device_state state)
{ {
int ret = 0; int ret = 0;
struct spi_nrfx_data *data = get_dev_data(dev); struct spi_nrfx_data *data = get_dev_data(dev);
@ -286,8 +286,8 @@ static int spi_nrfx_pm_control(const struct device *dev,
enum pm_device_state curr_state; enum pm_device_state curr_state;
(void)pm_device_state_get(dev, &curr_state); (void)pm_device_state_get(dev, &curr_state);
if (*state != curr_state) { if (state != curr_state) {
switch (*state) { switch (state) {
case PM_DEVICE_STATE_ACTIVE: case PM_DEVICE_STATE_ACTIVE:
ret = init_spi(dev); ret = init_spi(dev);
/* Force reconfiguration before next transfer */ /* Force reconfiguration before next transfer */

View file

@ -325,7 +325,7 @@ static int init_spim(const struct device *dev)
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
static int spim_nrfx_pm_control(const struct device *dev, static int spim_nrfx_pm_control(const struct device *dev,
enum pm_device_state *state) enum pm_device_state state)
{ {
int ret = 0; int ret = 0;
struct spi_nrfx_data *data = get_dev_data(dev); struct spi_nrfx_data *data = get_dev_data(dev);
@ -333,8 +333,8 @@ static int spim_nrfx_pm_control(const struct device *dev,
enum pm_device_state curr_state; enum pm_device_state curr_state;
(void)pm_device_state_get(dev, &curr_state); (void)pm_device_state_get(dev, &curr_state);
if (*state != curr_state) { if (state != curr_state) {
switch (*state) { switch (state) {
case PM_DEVICE_STATE_ACTIVE: case PM_DEVICE_STATE_ACTIVE:
ret = init_spim(dev); ret = init_spim(dev);
/* Force reconfiguration before next transfer */ /* Force reconfiguration before next transfer */

View file

@ -31,7 +31,7 @@ int __weak sys_clock_driver_init(const struct device *dev)
} }
int __weak sys_clock_device_ctrl(const struct device *dev, int __weak sys_clock_device_ctrl(const struct device *dev,
enum pm_device_state *state) enum pm_device_state state)
{ {
return -ENOSYS; return -ENOSYS;
} }

View file

@ -385,7 +385,7 @@ struct device {
#ifdef CONFIG_PM_DEVICE #ifdef CONFIG_PM_DEVICE
/** Power Management function */ /** Power Management function */
int (*pm_control)(const struct device *dev, int (*pm_control)(const struct device *dev,
enum pm_device_state *state); enum pm_device_state state);
/** Pointer to device instance power management data */ /** Pointer to device instance power management data */
struct pm_device * const pm; struct pm_device * const pm;
#endif #endif

View file

@ -47,7 +47,7 @@ extern int sys_clock_driver_init(const struct device *dev);
* if undefined in the clock driver. * if undefined in the clock driver.
*/ */
extern int clock_device_ctrl(const struct device *dev, extern int clock_device_ctrl(const struct device *dev,
enum pm_device_state *state); enum pm_device_state state);
/** /**
* @brief Set system clock timeout * @brief Set system clock timeout

View file

@ -87,9 +87,9 @@ static int dummy_close(const struct device *dev)
} }
static int dummy_device_pm_ctrl(const struct device *dev, static int dummy_device_pm_ctrl(const struct device *dev,
enum pm_device_state *state) enum pm_device_state state)
{ {
if (*state == PM_DEVICE_STATE_ACTIVE) { if (state == PM_DEVICE_STATE_ACTIVE) {
printk("child resuming..\n"); printk("child resuming..\n");
} else { } else {
printk("child suspending..\n"); printk("child suspending..\n");

View file

@ -25,9 +25,9 @@ static int dummy_transfer(const struct device *dev, uint32_t cmd,
} }
static int dummy_parent_pm_ctrl(const struct device *dev, static int dummy_parent_pm_ctrl(const struct device *dev,
enum pm_device_state *state) enum pm_device_state state)
{ {
if (*state == PM_DEVICE_STATE_ACTIVE) { if (state == PM_DEVICE_STATE_ACTIVE) {
printk("parent resuming..\n"); printk("parent resuming..\n");
} else { } else {
printk("parent suspending..\n"); printk("parent suspending..\n");

View file

@ -137,7 +137,7 @@ int pm_device_state_set(const struct device *dev,
return -ENOSYS; return -ENOSYS;
} }
ret = dev->pm_control(dev, &device_power_state); ret = dev->pm_control(dev, device_power_state);
if (ret < 0) { if (ret < 0) {
return ret; return ret;
} }

View file

@ -22,17 +22,17 @@ struct fake_dev_context {
}; };
static int fake_dev_pm_control(const struct device *dev, static int fake_dev_pm_control(const struct device *dev,
enum pm_device_state *state) enum pm_device_state state)
{ {
struct fake_dev_context *ctx = dev->data; struct fake_dev_context *ctx = dev->data;
int ret = 0; int ret = 0;
if (*state == PM_DEVICE_STATE_SUSPEND) { if (state == PM_DEVICE_STATE_SUSPEND) {
ret = net_if_suspend(ctx->iface); ret = net_if_suspend(ctx->iface);
if (ret == -EBUSY) { if (ret == -EBUSY) {
goto out; goto out;
} }
} else if (*state == PM_DEVICE_STATE_ACTIVE) { } else if (state == PM_DEVICE_STATE_ACTIVE) {
ret = net_if_resume(ctx->iface); ret = net_if_resume(ctx->iface);
} }

View file

@ -35,7 +35,7 @@ static int dummy_close_sync(const struct device *dev)
} }
static int dummy_device_pm_ctrl(const struct device *dev, static int dummy_device_pm_ctrl(const struct device *dev,
enum pm_device_state *state) enum pm_device_state state)
{ {
return 0; return 0;
} }

View file

@ -20,7 +20,7 @@ static int dummy_close(const struct device *dev)
} }
static int dummy_device_pm_ctrl(const struct device *dev, static int dummy_device_pm_ctrl(const struct device *dev,
enum pm_device_state *state) enum pm_device_state state)
{ {
return 0; return 0;
} }