pm: device: remove usage of ctrl_command
The callback is now invoked to set the device PM state in all cases, so the usage of ctrl_command is redundant. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
c2cf1ad203
commit
da0ff4ae46
37 changed files with 319 additions and 509 deletions
|
@ -505,8 +505,6 @@ static int st7735r_pm_control(const struct device *dev, uint32_t ctrl_command,
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct st7735r_data *data = (struct st7735r_data *)dev->data;
|
struct st7735r_data *data = (struct st7735r_data *)dev->data;
|
||||||
|
|
||||||
switch (ctrl_command) {
|
|
||||||
case PM_DEVICE_STATE_SET:
|
|
||||||
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) {
|
||||||
|
@ -519,11 +517,6 @@ static int st7735r_pm_control(const struct device *dev, uint32_t ctrl_command,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ret = -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_PM_DEVICE */
|
#endif /* CONFIG_PM_DEVICE */
|
||||||
|
|
|
@ -404,24 +404,15 @@ static void st7789v_enter_sleep(struct st7789v_data *data)
|
||||||
static int st7789v_pm_control(const struct device *dev, uint32_t ctrl_command,
|
static int st7789v_pm_control(const struct device *dev, uint32_t ctrl_command,
|
||||||
enum pm_device_state *state)
|
enum pm_device_state *state)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
|
||||||
struct st7789v_data *data = (struct st7789v_data *)dev->data;
|
struct st7789v_data *data = (struct st7789v_data *)dev->data;
|
||||||
|
|
||||||
switch (ctrl_command) {
|
|
||||||
case DEVICE_PM_SET_POWER_STATE:
|
|
||||||
if (*state == PM_DEVICE_STATE_ACTIVE) {
|
if (*state == PM_DEVICE_STATE_ACTIVE) {
|
||||||
st7789v_exit_sleep(data);
|
st7789v_exit_sleep(data);
|
||||||
ret = 0;
|
|
||||||
} else {
|
} else {
|
||||||
st7789v_enter_sleep(data);
|
st7789v_enter_sleep(data);
|
||||||
ret = 0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ret = -EINVAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_PM_DEVICE */
|
#endif /* CONFIG_PM_DEVICE */
|
||||||
|
|
||||||
|
|
|
@ -295,15 +295,12 @@ 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;
|
||||||
|
|
||||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,7 +198,6 @@ static int eth_mcux_device_pm_control(const struct device *dev,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == PM_DEVICE_STATE_SET) {
|
|
||||||
if (*state == PM_DEVICE_STATE_SUSPEND) {
|
if (*state == PM_DEVICE_STATE_SUSPEND) {
|
||||||
LOG_DBG("Suspending");
|
LOG_DBG("Suspending");
|
||||||
|
|
||||||
|
@ -222,9 +221,6 @@ static int eth_mcux_device_pm_control(const struct device *dev,
|
||||||
eth_mcux_init(dev);
|
eth_mcux_init(dev);
|
||||||
net_if_resume(eth_ctx->iface);
|
net_if_resume(eth_ctx->iface);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
||||||
|
|
|
@ -630,8 +630,6 @@ static int spi_flash_at45_pm_control(const struct device *dev,
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
|
||||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
|
||||||
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);
|
||||||
|
@ -659,7 +657,6 @@ static int spi_flash_at45_pm_control(const struct device *dev,
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
|
@ -447,13 +447,11 @@ static int gpio_dw_device_ctrl(const struct device *port,
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -599,20 +599,12 @@ 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;
|
||||||
|
|
||||||
switch (ctrl_command) {
|
|
||||||
case PM_DEVICE_STATE_SET:
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ret = -EINVAL;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -369,8 +369,6 @@ 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;
|
||||||
|
|
||||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
|
||||||
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);
|
||||||
|
@ -378,7 +376,6 @@ static int i2c_cc13xx_cc26xx_pm_control(const struct device *dev,
|
||||||
ret = i2c_cc13xx_cc26xx_set_power_state(dev,
|
ret = i2c_cc13xx_cc26xx_set_power_state(dev,
|
||||||
new_state);
|
new_state);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,8 +221,6 @@ 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;
|
||||||
|
|
||||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
|
||||||
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);
|
||||||
|
@ -249,7 +247,6 @@ static int twi_nrfx_pm_control(const struct device *dev,
|
||||||
ret = -ENOTSUP;
|
ret = -ENOTSUP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -259,8 +259,6 @@ 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;
|
||||||
|
|
||||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
|
||||||
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);
|
||||||
|
@ -288,7 +286,6 @@ static int twim_nrfx_pm_control(const struct device *dev,
|
||||||
ret = -ENOTSUP;
|
ret = -ENOTSUP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,13 +181,11 @@ static int arc_v2_irq_unit_device_ctrl(const struct device *dev,
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
unsigned int key = arch_irq_lock();
|
unsigned int key = arch_irq_lock();
|
||||||
|
|
||||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
arch_irq_unlock(key);
|
arch_irq_unlock(key);
|
||||||
|
|
||||||
|
|
|
@ -314,8 +314,6 @@ 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;
|
||||||
|
|
||||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
|
||||||
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);
|
||||||
|
@ -335,7 +333,6 @@ static int ioapic_device_ctrl(const struct device *dev,
|
||||||
default:
|
default:
|
||||||
ret = -ENOTSUP;
|
ret = -ENOTSUP;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -414,13 +414,11 @@ static int loapic_device_ctrl(const struct device *port,
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,19 +145,7 @@ static int led_pwm_pm_set_state(const struct device *dev,
|
||||||
static int led_pwm_pm_control(const struct device *dev, uint32_t ctrl_command,
|
static int led_pwm_pm_control(const struct device *dev, uint32_t ctrl_command,
|
||||||
enum pm_device_state *state)
|
enum pm_device_state *state)
|
||||||
{
|
{
|
||||||
int err;
|
return led_pwm_pm_set_state(dev, *state);
|
||||||
|
|
||||||
switch (ctrl_command) {
|
|
||||||
case PM_DEVICE_STATE_SET:
|
|
||||||
err = led_pwm_pm_set_state(dev, *state);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
err = -ENOTSUP;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_PM_DEVICE */
|
#endif /* CONFIG_PM_DEVICE */
|
||||||
|
|
|
@ -322,15 +322,11 @@ 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;
|
||||||
|
|
||||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
|
||||||
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,
|
err = pwm_nrfx_set_power_state(*state, current_state, dev);
|
||||||
dev);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
|
|
|
@ -416,7 +416,6 @@ static int apds9960_device_ctrl(const struct device *dev,
|
||||||
struct apds9960_data *data = dev->data;
|
struct apds9960_data *data = dev->data;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
|
||||||
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,
|
||||||
|
@ -439,8 +438,6 @@ static int apds9960_device_ctrl(const struct device *dev,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -414,9 +414,6 @@ int bme280_pm_ctrl(const struct device *dev, uint32_t ctrl_command,
|
||||||
enum pm_device_state *state)
|
enum pm_device_state *state)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
/* Set power state */
|
|
||||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
|
||||||
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);
|
||||||
|
@ -441,7 +438,6 @@ int bme280_pm_ctrl(const struct device *dev, uint32_t ctrl_command,
|
||||||
ret);
|
ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -588,9 +588,7 @@ static int bmp388_device_ctrl(
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
|
||||||
ret = bmp388_set_power_state(dev, *state);
|
ret = bmp388_set_power_state(dev, *state);
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -737,8 +737,6 @@ static int bq274xx_pm_control(const struct device *dev, uint32_t ctrl_command,
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct bq274xx_data *data = dev->data;
|
struct bq274xx_data *data = dev->data;
|
||||||
|
|
||||||
switch (ctrl_command) {
|
|
||||||
case PM_DEVICE_STATE_SET:
|
|
||||||
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) {
|
||||||
|
@ -753,10 +751,6 @@ static int bq274xx_pm_control(const struct device *dev, uint32_t ctrl_command,
|
||||||
LOG_ERR("State to set is not implemented");
|
LOG_ERR("State to set is not implemented");
|
||||||
ret = -ENOTSUP;
|
ret = -ENOTSUP;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ret = -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -540,9 +540,8 @@ static int fdc2x1x_device_pm_ctrl(const struct device *dev,
|
||||||
{
|
{
|
||||||
struct fdc2x1x_data *data = dev->data;
|
struct fdc2x1x_data *data = dev->data;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
|
||||||
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) {
|
||||||
|
@ -557,7 +556,6 @@ static int fdc2x1x_device_pm_ctrl(const struct device *dev,
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -481,20 +481,11 @@ static int lis2mdl_pm_control(const struct device *dev, uint32_t ctrl_command,
|
||||||
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;
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
|
||||||
switch (ctrl_command) {
|
|
||||||
case PM_DEVICE_STATE_SET:
|
|
||||||
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,
|
status = lis2mdl_set_power_state(lis2mdl, config, *state);
|
||||||
*state);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
LOG_ERR("Got unknown power management control command");
|
|
||||||
status = -EINVAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
|
|
|
@ -248,15 +248,7 @@ static int qdec_nrfx_pm_control(const struct device *dev,
|
||||||
|
|
||||||
LOG_DBG("");
|
LOG_DBG("");
|
||||||
|
|
||||||
switch (ctrl_command) {
|
|
||||||
case PM_DEVICE_STATE_SET:
|
|
||||||
err = qdec_nrfx_pm_set_state(data, *state);
|
err = qdec_nrfx_pm_set_state(data, *state);
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
err = -ENOTSUP;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,13 +222,7 @@ static int sgp40_pm_ctrl(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
enum pm_device_state *state)
|
enum pm_device_state *state)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
return sgp40_set_power_state(dev, *state);
|
||||||
|
|
||||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
|
||||||
rc = sgp40_set_power_state(dev, *state);
|
|
||||||
}
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_PM_DEVICE */
|
#endif /* CONFIG_PM_DEVICE */
|
||||||
|
|
||||||
|
|
|
@ -223,8 +223,6 @@ 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;
|
||||||
|
|
||||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
|
||||||
uint16_t ps_conf;
|
uint16_t ps_conf;
|
||||||
|
|
||||||
ret = vcnl4040_read(dev, VCNL4040_REG_PS_CONF, &ps_conf);
|
ret = vcnl4040_read(dev, VCNL4040_REG_PS_CONF, &ps_conf);
|
||||||
|
@ -273,8 +271,6 @@ static int vcnl4040_device_ctrl(const struct device *dev,
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -445,15 +445,12 @@ 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;
|
||||||
|
|
||||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -460,17 +460,7 @@ static inline int uart_npcx_set_power_state(const struct device *dev,
|
||||||
static int uart_npcx_pm_control(const struct device *dev, uint32_t ctrl_command,
|
static int uart_npcx_pm_control(const struct device *dev, uint32_t ctrl_command,
|
||||||
enum pm_device_state *state)
|
enum pm_device_state *state)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
return uart_npcx_set_power_state(dev, *state);
|
||||||
|
|
||||||
switch (ctrl_command) {
|
|
||||||
case PM_DEVICE_STATE_SET:
|
|
||||||
ret = uart_npcx_set_power_state(dev, *state);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ret = -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_PM_DEVICE */
|
#endif /* CONFIG_PM_DEVICE */
|
||||||
|
|
||||||
|
|
|
@ -1162,14 +1162,12 @@ static int uart_nrfx_pm_control(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
enum pm_device_state *state)
|
enum pm_device_state *state)
|
||||||
{
|
{
|
||||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
|
||||||
enum pm_device_state current_state;
|
enum pm_device_state current_state;
|
||||||
|
|
||||||
(void)pm_device_state_get(dev, ¤t_state);
|
(void)pm_device_state_get(dev, ¤t_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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1927,14 +1927,10 @@ static int uarte_nrfx_pm_control(const struct device *dev,
|
||||||
{
|
{
|
||||||
enum pm_device_state curr_state;
|
enum pm_device_state curr_state;
|
||||||
|
|
||||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1463,14 +1463,12 @@ static int uart_stm32_pm_control(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
enum pm_device_state *state)
|
enum pm_device_state *state)
|
||||||
{
|
{
|
||||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -252,15 +252,12 @@ 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;
|
||||||
|
|
||||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -284,8 +284,6 @@ static int spi_nrfx_pm_control(const struct device *dev,
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct spi_nrfx_data *data = get_dev_data(dev);
|
struct spi_nrfx_data *data = get_dev_data(dev);
|
||||||
const struct spi_nrfx_config *config = get_dev_config(dev);
|
const struct spi_nrfx_config *config = get_dev_config(dev);
|
||||||
|
|
||||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
|
||||||
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);
|
||||||
|
@ -309,7 +307,6 @@ static int spi_nrfx_pm_control(const struct device *dev,
|
||||||
ret = -ENOTSUP;
|
ret = -ENOTSUP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -331,8 +331,6 @@ static int spim_nrfx_pm_control(const struct device *dev,
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct spi_nrfx_data *data = get_dev_data(dev);
|
struct spi_nrfx_data *data = get_dev_data(dev);
|
||||||
const struct spi_nrfx_config *config = get_dev_config(dev);
|
const struct spi_nrfx_config *config = get_dev_config(dev);
|
||||||
|
|
||||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
|
||||||
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);
|
||||||
|
@ -356,7 +354,6 @@ static int spim_nrfx_pm_control(const struct device *dev,
|
||||||
ret = -ENOTSUP;
|
ret = -ENOTSUP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,25 +90,14 @@ static int dummy_device_pm_ctrl(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
enum pm_device_state *state)
|
enum pm_device_state *state)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
switch (ctrl_command) {
|
|
||||||
case PM_DEVICE_STATE_SET:
|
|
||||||
if (*state == PM_DEVICE_STATE_ACTIVE) {
|
if (*state == PM_DEVICE_STATE_ACTIVE) {
|
||||||
printk("child resuming..\n");
|
printk("child resuming..\n");
|
||||||
return 0;
|
|
||||||
} else {
|
} else {
|
||||||
printk("child suspending..\n");
|
printk("child suspending..\n");
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ret = -EINVAL;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct dummy_driver_api funcs = {
|
static const struct dummy_driver_api funcs = {
|
||||||
.open = dummy_open,
|
.open = dummy_open,
|
||||||
|
|
|
@ -28,25 +28,14 @@ static int dummy_parent_pm_ctrl(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
enum pm_device_state *state)
|
enum pm_device_state *state)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
switch (ctrl_command) {
|
|
||||||
case PM_DEVICE_STATE_SET:
|
|
||||||
if (*state == PM_DEVICE_STATE_ACTIVE) {
|
if (*state == PM_DEVICE_STATE_ACTIVE) {
|
||||||
printk("parent resuming..\n");
|
printk("parent resuming..\n");
|
||||||
return 0;
|
|
||||||
} else {
|
} else {
|
||||||
printk("parent suspending..\n");
|
printk("parent suspending..\n");
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ret = -EINVAL;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct dummy_parent_api funcs = {
|
static const struct dummy_parent_api funcs = {
|
||||||
.transfer = dummy_transfer,
|
.transfer = dummy_transfer,
|
||||||
|
|
|
@ -27,7 +27,6 @@ static int fake_dev_pm_control(const struct device *dev, uint32_t command,
|
||||||
struct fake_dev_context *ctx = dev->data;
|
struct fake_dev_context *ctx = dev->data;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (command == PM_DEVICE_STATE_SET) {
|
|
||||||
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) {
|
||||||
|
@ -36,9 +35,6 @@ static int fake_dev_pm_control(const struct device *dev, uint32_t command,
|
||||||
} 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);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
||||||
|
|
|
@ -38,18 +38,7 @@ static int dummy_device_pm_ctrl(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
enum pm_device_state *state)
|
enum pm_device_state *state)
|
||||||
{
|
{
|
||||||
int ret;
|
return 0;
|
||||||
|
|
||||||
switch (ctrl_command) {
|
|
||||||
case PM_DEVICE_STATE_SET:
|
|
||||||
ret = 0;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ret = -EINVAL;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct dummy_driver_api funcs = {
|
static const struct dummy_driver_api funcs = {
|
||||||
|
|
|
@ -23,18 +23,7 @@ static int dummy_device_pm_ctrl(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
enum pm_device_state *state)
|
enum pm_device_state *state)
|
||||||
{
|
{
|
||||||
int ret;
|
return 0;
|
||||||
|
|
||||||
switch (ctrl_command) {
|
|
||||||
case PM_DEVICE_STATE_SET:
|
|
||||||
ret = 0;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ret = -EINVAL;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct dummy_driver_api funcs = {
|
static const struct dummy_driver_api funcs = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue