power: device: void *context -> uint32_t *state
The context parameter used across device power management is actually the power state. Just use it and avoid a lot of unnecessary casts. Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
parent
9ac646f277
commit
7eba310220
30 changed files with 111 additions and 109 deletions
|
@ -409,14 +409,14 @@ 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,
|
||||||
void *context, pm_device_cb cb, void *arg)
|
uint32_t *state, pm_device_cb cb, void *arg)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct st7789v_data *data = (struct st7789v_data *)dev->data;
|
struct st7789v_data *data = (struct st7789v_data *)dev->data;
|
||||||
|
|
||||||
switch (ctrl_command) {
|
switch (ctrl_command) {
|
||||||
case PM_DEVICE_STATE_SET:
|
case DEVICE_PM_SET_POWER_STATE:
|
||||||
if (*((uint32_t *)context) == PM_DEVICE_ACTIVE_STATE) {
|
if (*state == PM_DEVICE_ACTIVE_STATE) {
|
||||||
st7789v_exit_sleep(data);
|
st7789v_exit_sleep(data);
|
||||||
data->pm_state = PM_DEVICE_ACTIVE_STATE;
|
data->pm_state = PM_DEVICE_ACTIVE_STATE;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
@ -427,14 +427,14 @@ static int st7789v_pm_control(const struct device *dev, uint32_t ctrl_command,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PM_DEVICE_STATE_GET:
|
case PM_DEVICE_STATE_GET:
|
||||||
*((uint32_t *)context) = data->pm_state;
|
*state = data->pm_state;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cb != NULL) {
|
if (cb != NULL) {
|
||||||
cb(dev, ret, context, arg);
|
cb(dev, ret, state, arg);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -293,14 +293,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,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
void *context, pm_device_cb cb,
|
uint32_t *state, pm_device_cb cb,
|
||||||
void *arg)
|
void *arg)
|
||||||
{
|
{
|
||||||
struct entropy_cc13xx_cc26xx_data *data = get_dev_data(dev);
|
struct entropy_cc13xx_cc26xx_data *data = get_dev_data(dev);
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
||||||
uint32_t new_state = *((const uint32_t *)context);
|
uint32_t new_state = *state;
|
||||||
|
|
||||||
if (new_state != data->pm_state) {
|
if (new_state != data->pm_state) {
|
||||||
ret = entropy_cc13xx_cc26xx_set_power_state(dev,
|
ret = entropy_cc13xx_cc26xx_set_power_state(dev,
|
||||||
|
@ -308,11 +308,11 @@ static int entropy_cc13xx_cc26xx_pm_control(const struct device *dev,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
__ASSERT_NO_MSG(ctrl_command == PM_DEVICE_STATE_GET);
|
__ASSERT_NO_MSG(ctrl_command == PM_DEVICE_STATE_GET);
|
||||||
*((uint32_t *)context) = data->pm_state;
|
*state = data->pm_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cb) {
|
if (cb) {
|
||||||
cb(dev, ret, context, arg);
|
cb(dev, ret, state, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -186,7 +186,8 @@ 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,
|
||||||
uint32_t command,
|
uint32_t command,
|
||||||
void *context, pm_device_cb cb, void *arg)
|
uint32_t *state, pm_device_cb cb,
|
||||||
|
void *arg)
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
@ -199,7 +200,7 @@ static int eth_mcux_device_pm_control(const struct device *dev,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == PM_DEVICE_STATE_SET) {
|
if (command == PM_DEVICE_STATE_SET) {
|
||||||
if (*(uint32_t *)context == PM_DEVICE_SUSPEND_STATE) {
|
if (*state == PM_DEVICE_SUSPEND_STATE) {
|
||||||
LOG_DBG("Suspending");
|
LOG_DBG("Suspending");
|
||||||
|
|
||||||
ret = net_if_suspend(eth_ctx->iface);
|
ret = net_if_suspend(eth_ctx->iface);
|
||||||
|
@ -214,7 +215,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 (*(uint32_t *)context == PM_DEVICE_ACTIVE_STATE) {
|
} else if (*state == PM_DEVICE_ACTIVE_STATE) {
|
||||||
LOG_DBG("Resuming");
|
LOG_DBG("Resuming");
|
||||||
|
|
||||||
clock_control_on(eth_ctx->clock_dev,
|
clock_control_on(eth_ctx->clock_dev,
|
||||||
|
@ -228,7 +229,7 @@ static int eth_mcux_device_pm_control(const struct device *dev,
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (cb) {
|
if (cb) {
|
||||||
cb(dev, ret, context, arg);
|
cb(dev, ret, state, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -629,14 +629,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,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
void *context, pm_device_cb cb, void *arg)
|
uint32_t *state, pm_device_cb cb,
|
||||||
|
void *arg)
|
||||||
{
|
{
|
||||||
struct spi_flash_at45_data *dev_data = get_dev_data(dev);
|
struct spi_flash_at45_data *dev_data = get_dev_data(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) {
|
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
||||||
uint32_t new_state = *((const uint32_t *)context);
|
uint32_t new_state = *state;
|
||||||
|
|
||||||
if (new_state != dev_data->pm_state) {
|
if (new_state != dev_data->pm_state) {
|
||||||
switch (new_state) {
|
switch (new_state) {
|
||||||
|
@ -666,11 +667,11 @@ static int spi_flash_at45_pm_control(const struct device *dev,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
__ASSERT_NO_MSG(ctrl_command == PM_DEVICE_STATE_GET);
|
__ASSERT_NO_MSG(ctrl_command == PM_DEVICE_STATE_GET);
|
||||||
*((uint32_t *)context) = dev_data->pm_state;
|
*state = dev_data->pm_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cb) {
|
if (cb) {
|
||||||
cb(dev, err, context, arg);
|
cb(dev, err, state, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
|
|
|
@ -605,7 +605,7 @@ 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,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
void *context, pm_device_cb cb, void *arg)
|
uint32_t *state, pm_device_cb cb, void *arg)
|
||||||
{
|
{
|
||||||
struct gpio_stm32_data *data = dev->data;
|
struct gpio_stm32_data *data = dev->data;
|
||||||
uint32_t new_state;
|
uint32_t new_state;
|
||||||
|
@ -613,13 +613,13 @@ static int gpio_stm32_pm_device_ctrl(const struct device *dev,
|
||||||
|
|
||||||
switch (ctrl_command) {
|
switch (ctrl_command) {
|
||||||
case PM_DEVICE_STATE_SET:
|
case PM_DEVICE_STATE_SET:
|
||||||
new_state = *((const uint32_t *)context);
|
new_state = *state;
|
||||||
if (new_state != data->power_state) {
|
if (new_state != data->power_state) {
|
||||||
ret = gpio_stm32_set_power_state(dev, new_state);
|
ret = gpio_stm32_set_power_state(dev, new_state);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PM_DEVICE_STATE_GET:
|
case PM_DEVICE_STATE_GET:
|
||||||
*((uint32_t *)context) = gpio_stm32_get_power_state(dev);
|
*state = gpio_stm32_get_power_state(dev);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
|
@ -627,7 +627,7 @@ static int gpio_stm32_pm_device_ctrl(const struct device *dev,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cb) {
|
if (cb) {
|
||||||
cb(dev, ret, context, arg);
|
cb(dev, ret, state, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -368,13 +368,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,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
void *context, pm_device_cb cb,
|
uint32_t *state, pm_device_cb cb,
|
||||||
void *arg)
|
void *arg)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
||||||
uint32_t new_state = *((const uint32_t *)context);
|
uint32_t new_state = *state;
|
||||||
|
|
||||||
if (new_state != get_dev_data(dev)->pm_state) {
|
if (new_state != get_dev_data(dev)->pm_state) {
|
||||||
ret = i2c_cc13xx_cc26xx_set_power_state(dev,
|
ret = i2c_cc13xx_cc26xx_set_power_state(dev,
|
||||||
|
@ -382,11 +382,11 @@ static int i2c_cc13xx_cc26xx_pm_control(const struct device *dev,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
__ASSERT_NO_MSG(ctrl_command == PM_DEVICE_STATE_GET);
|
__ASSERT_NO_MSG(ctrl_command == PM_DEVICE_STATE_GET);
|
||||||
*((uint32_t *)context) = get_dev_data(dev)->pm_state;
|
*state = get_dev_data(dev)->pm_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cb) {
|
if (cb) {
|
||||||
cb(dev, ret, context, arg);
|
cb(dev, ret, state, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -224,13 +224,13 @@ 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,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
void *context, pm_device_cb cb, void *arg)
|
uint32_t *state, pm_device_cb cb, void *arg)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
uint32_t pm_current_state = get_dev_data(dev)->pm_state;
|
uint32_t pm_current_state = get_dev_data(dev)->pm_state;
|
||||||
|
|
||||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
||||||
uint32_t new_state = *((const uint32_t *)context);
|
uint32_t new_state = *state;
|
||||||
|
|
||||||
if (new_state != pm_current_state) {
|
if (new_state != pm_current_state) {
|
||||||
switch (new_state) {
|
switch (new_state) {
|
||||||
|
@ -260,11 +260,11 @@ static int twi_nrfx_pm_control(const struct device *dev,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
__ASSERT_NO_MSG(ctrl_command == PM_DEVICE_STATE_GET);
|
__ASSERT_NO_MSG(ctrl_command == PM_DEVICE_STATE_GET);
|
||||||
*((uint32_t *)context) = get_dev_data(dev)->pm_state;
|
*state = get_dev_data(dev)->pm_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cb) {
|
if (cb) {
|
||||||
cb(dev, ret, context, arg);
|
cb(dev, ret, state, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -263,13 +263,13 @@ 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,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
void *context, pm_device_cb cb, void *arg)
|
uint32_t *state, pm_device_cb cb, void *arg)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
uint32_t pm_current_state = get_dev_data(dev)->pm_state;
|
uint32_t pm_current_state = get_dev_data(dev)->pm_state;
|
||||||
|
|
||||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
||||||
uint32_t new_state = *((const uint32_t *)context);
|
uint32_t new_state = *state;
|
||||||
|
|
||||||
if (new_state != pm_current_state) {
|
if (new_state != pm_current_state) {
|
||||||
switch (new_state) {
|
switch (new_state) {
|
||||||
|
@ -300,11 +300,11 @@ static int twim_nrfx_pm_control(const struct device *dev,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
__ASSERT_NO_MSG(ctrl_command == PM_DEVICE_STATE_GET);
|
__ASSERT_NO_MSG(ctrl_command == PM_DEVICE_STATE_GET);
|
||||||
*((uint32_t *)context) = get_dev_data(dev)->pm_state;
|
*state = get_dev_data(dev)->pm_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cb) {
|
if (cb) {
|
||||||
cb(dev, ret, context, arg);
|
cb(dev, ret, state, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -192,7 +192,7 @@ static int arc_v2_irq_unit_get_state(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,
|
||||||
uint32_t ctrl_command, void *context,
|
uint32_t ctrl_command, uint32_t *context,
|
||||||
pm_device_cb cb, void *arg)
|
pm_device_cb cb, void *arg)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
|
@ -303,7 +303,7 @@ int ioapic_resume_from_suspend(const struct device *port)
|
||||||
*/
|
*/
|
||||||
static int ioapic_device_ctrl(const struct device *dev,
|
static int ioapic_device_ctrl(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
void *context, pm_device_cb cb, void *arg)
|
uint32_t *context, pm_device_cb cb, void *arg)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
|
|
@ -404,18 +404,18 @@ int loapic_resume(const struct device *port)
|
||||||
*/
|
*/
|
||||||
static int loapic_device_ctrl(const struct device *port,
|
static int loapic_device_ctrl(const struct device *port,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
void *context, pm_device_cb cb, void *arg)
|
uint32_t *context, pm_device_cb cb, void *arg)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
||||||
if (*((uint32_t *)context) == PM_DEVICE_SUSPEND_STATE) {
|
if (*context == PM_DEVICE_SUSPEND_STATE) {
|
||||||
ret = loapic_suspend(port);
|
ret = loapic_suspend(port);
|
||||||
} else if (*((uint32_t *)context) == PM_DEVICE_ACTIVE_STATE) {
|
} else if (*context == PM_DEVICE_ACTIVE_STATE) {
|
||||||
ret = loapic_resume(port);
|
ret = loapic_resume(port);
|
||||||
}
|
}
|
||||||
} else if (ctrl_command == PM_DEVICE_STATE_GET) {
|
} else if (ctrl_command == PM_DEVICE_STATE_GET) {
|
||||||
*((uint32_t *)context) = loapic_device_power_state;
|
*context = loapic_device_power_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cb) {
|
if (cb) {
|
||||||
|
|
|
@ -317,25 +317,25 @@ static int pwm_nrfx_set_power_state(uint32_t new_state,
|
||||||
|
|
||||||
static int pwm_nrfx_pm_control(const struct device *dev,
|
static int pwm_nrfx_pm_control(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
void *context,
|
uint32_t *state,
|
||||||
uint32_t *current_state)
|
uint32_t *current_state)
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
||||||
uint32_t new_state = *((const uint32_t *)context);
|
uint32_t new_state = *((const uint32_t *)state);
|
||||||
|
|
||||||
if (new_state != (*current_state)) {
|
if (new_state != (*current_state)) {
|
||||||
err = pwm_nrfx_set_power_state(new_state,
|
err = pwm_nrfx_set_power_state(new_state,
|
||||||
*current_state,
|
*current_state,
|
||||||
dev);
|
dev);
|
||||||
if (!err) {
|
if (!err) {
|
||||||
(*current_state) = new_state;
|
*current_state = new_state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
__ASSERT_NO_MSG(ctrl_command == PM_DEVICE_STATE_GET);
|
__ASSERT_NO_MSG(ctrl_command == PM_DEVICE_STATE_GET);
|
||||||
*((uint32_t *)context) = (*current_state);
|
*state = *current_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
|
@ -344,16 +344,16 @@ 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, \
|
||||||
uint32_t ctrl_command, \
|
uint32_t ctrl_command, \
|
||||||
void *context, \
|
uint32_t *state, \
|
||||||
pm_device_cb cb, \
|
pm_device_cb cb, \
|
||||||
void *arg) \
|
void *arg) \
|
||||||
{ \
|
{ \
|
||||||
static uint32_t current_state = PM_DEVICE_ACTIVE_STATE; \
|
static uint32_t current_state = PM_DEVICE_ACTIVE_STATE; \
|
||||||
int ret = 0; \
|
int ret = 0; \
|
||||||
ret = pwm_nrfx_pm_control(dev, ctrl_command, context, \
|
ret = pwm_nrfx_pm_control(dev, ctrl_command, state, \
|
||||||
¤t_state); \
|
¤t_state); \
|
||||||
if (cb) { \
|
if (cb) { \
|
||||||
cb(dev, ret, context, arg); \
|
cb(dev, ret, state, arg); \
|
||||||
} \
|
} \
|
||||||
return ret; \
|
return ret; \
|
||||||
}
|
}
|
||||||
|
|
|
@ -520,7 +520,7 @@ static int lis2mdl_set_power_state(struct lis2mdl_data *lis2mdl,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int lis2mdl_pm_control(const struct device *dev, uint32_t ctrl_command,
|
static int lis2mdl_pm_control(const struct device *dev, uint32_t ctrl_command,
|
||||||
void *context, pm_device_cb cb, void *arg)
|
uint32_t *state, pm_device_cb cb, void *arg)
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
@ -530,14 +530,14 @@ static int lis2mdl_pm_control(const struct device *dev, uint32_t ctrl_command,
|
||||||
|
|
||||||
switch (ctrl_command) {
|
switch (ctrl_command) {
|
||||||
case PM_DEVICE_STATE_SET:
|
case PM_DEVICE_STATE_SET:
|
||||||
new_state = *((const uint32_t *)context);
|
new_state = *state;
|
||||||
if (new_state != current_state) {
|
if (new_state != current_state) {
|
||||||
status = lis2mdl_set_power_state(lis2mdl, config,
|
status = lis2mdl_set_power_state(lis2mdl, config,
|
||||||
new_state);
|
new_state);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PM_DEVICE_STATE_GET:
|
case PM_DEVICE_STATE_GET:
|
||||||
*((uint32_t *)context) = current_state;
|
*state = current_state;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LOG_ERR("Got unknown power management control command");
|
LOG_ERR("Got unknown power management control command");
|
||||||
|
@ -545,7 +545,7 @@ static int lis2mdl_pm_control(const struct device *dev, uint32_t ctrl_command,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cb) {
|
if (cb) {
|
||||||
cb(dev, status, context, arg);
|
cb(dev, status, state, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
|
|
|
@ -218,7 +218,7 @@ static int qdec_nrfx_init(const struct device *dev)
|
||||||
#ifdef CONFIG_PM_DEVICE
|
#ifdef CONFIG_PM_DEVICE
|
||||||
|
|
||||||
static int qdec_nrfx_pm_get_state(struct qdec_nrfx_data *data,
|
static int qdec_nrfx_pm_get_state(struct qdec_nrfx_data *data,
|
||||||
uint32_t *state)
|
uint32_t *state)
|
||||||
{
|
{
|
||||||
unsigned int key = irq_lock();
|
unsigned int key = irq_lock();
|
||||||
*state = data->pm_state;
|
*state = data->pm_state;
|
||||||
|
@ -228,7 +228,7 @@ static int qdec_nrfx_pm_get_state(struct qdec_nrfx_data *data,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int qdec_nrfx_pm_set_state(struct qdec_nrfx_data *data,
|
static int qdec_nrfx_pm_set_state(struct qdec_nrfx_data *data,
|
||||||
uint32_t new_state)
|
uint32_t new_state)
|
||||||
{
|
{
|
||||||
uint32_t old_state;
|
uint32_t old_state;
|
||||||
unsigned int key;
|
unsigned int key;
|
||||||
|
@ -268,7 +268,7 @@ 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,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
void *context, pm_device_cb cb, void *arg)
|
uint32_t *state, pm_device_cb cb, void *arg)
|
||||||
{
|
{
|
||||||
struct qdec_nrfx_data *data = &qdec_nrfx_data;
|
struct qdec_nrfx_data *data = &qdec_nrfx_data;
|
||||||
int err;
|
int err;
|
||||||
|
@ -277,11 +277,11 @@ static int qdec_nrfx_pm_control(const struct device *dev,
|
||||||
|
|
||||||
switch (ctrl_command) {
|
switch (ctrl_command) {
|
||||||
case PM_DEVICE_STATE_GET:
|
case PM_DEVICE_STATE_GET:
|
||||||
err = qdec_nrfx_pm_get_state(data, context);
|
err = qdec_nrfx_pm_get_state(data, state);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PM_DEVICE_STATE_SET:
|
case PM_DEVICE_STATE_SET:
|
||||||
err = qdec_nrfx_pm_set_state(data, *((uint32_t *)context));
|
err = qdec_nrfx_pm_set_state(data, *state);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -290,7 +290,7 @@ static int qdec_nrfx_pm_control(const struct device *dev,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cb) {
|
if (cb) {
|
||||||
cb(dev, err, context, arg);
|
cb(dev, err, state, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
|
|
|
@ -444,13 +444,13 @@ 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,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
void *context, pm_device_cb cb,
|
uint32_t *state, pm_device_cb cb,
|
||||||
void *arg)
|
void *arg)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
||||||
uint32_t new_state = *((const uint32_t *)context);
|
uint32_t new_state = *state;
|
||||||
|
|
||||||
if (new_state != get_dev_data(dev)->pm_state) {
|
if (new_state != get_dev_data(dev)->pm_state) {
|
||||||
ret = uart_cc13xx_cc26xx_set_power_state(dev,
|
ret = uart_cc13xx_cc26xx_set_power_state(dev,
|
||||||
|
@ -458,11 +458,11 @@ static int uart_cc13xx_cc26xx_pm_control(const struct device *dev,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
__ASSERT_NO_MSG(ctrl_command == PM_DEVICE_STATE_GET);
|
__ASSERT_NO_MSG(ctrl_command == PM_DEVICE_STATE_GET);
|
||||||
*((uint32_t *)context) = get_dev_data(dev)->pm_state;
|
*state = get_dev_data(dev)->pm_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cb) {
|
if (cb) {
|
||||||
cb(dev, ret, context, arg);
|
cb(dev, ret, state, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -470,23 +470,23 @@ 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, uint32_t ctrl_command,
|
static int uart_npcx_pm_control(const struct device *dev, uint32_t ctrl_command,
|
||||||
void *context, pm_device_cb cb, void *arg)
|
uint32_t *state, pm_device_cb cb, void *arg)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
switch (ctrl_command) {
|
switch (ctrl_command) {
|
||||||
case PM_DEVICE_STATE_SET:
|
case PM_DEVICE_STATE_SET:
|
||||||
ret = uart_npcx_set_power_state(dev, *((uint32_t *)context));
|
ret = uart_npcx_set_power_state(dev, *state);
|
||||||
break;
|
break;
|
||||||
case PM_DEVICE_STATE_GET:
|
case PM_DEVICE_STATE_GET:
|
||||||
ret = uart_npcx_get_power_state(dev, (uint32_t *)context);
|
ret = uart_npcx_get_power_state(dev, state);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cb != NULL) {
|
if (cb != NULL) {
|
||||||
cb(dev, ret, context, arg);
|
cb(dev, ret, state, arg);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1158,12 +1158,12 @@ 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,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
void *context, pm_device_cb cb, void *arg)
|
uint32_t *state, pm_device_cb cb, void *arg)
|
||||||
{
|
{
|
||||||
static uint32_t current_state = PM_DEVICE_ACTIVE_STATE;
|
static uint32_t current_state = PM_DEVICE_ACTIVE_STATE;
|
||||||
|
|
||||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
||||||
uint32_t new_state = *((const uint32_t *)context);
|
uint32_t new_state = *state;
|
||||||
|
|
||||||
if (new_state != current_state) {
|
if (new_state != current_state) {
|
||||||
uart_nrfx_set_power_state(dev, new_state);
|
uart_nrfx_set_power_state(dev, new_state);
|
||||||
|
@ -1171,11 +1171,11 @@ static int uart_nrfx_pm_control(const struct device *dev,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
__ASSERT_NO_MSG(ctrl_command == PM_DEVICE_STATE_GET);
|
__ASSERT_NO_MSG(ctrl_command == PM_DEVICE_STATE_GET);
|
||||||
*((uint32_t *)context) = current_state;
|
*state = current_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cb) {
|
if (cb) {
|
||||||
cb(dev, 0, context, arg);
|
cb(dev, 0, state, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -1865,23 +1865,23 @@ 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,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
void *context, pm_device_cb cb, void *arg)
|
uint32_t *state, pm_device_cb cb, void *arg)
|
||||||
{
|
{
|
||||||
struct uarte_nrfx_data *data = get_dev_data(dev);
|
struct uarte_nrfx_data *data = get_dev_data(dev);
|
||||||
|
|
||||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
||||||
uint32_t new_state = *((const uint32_t *)context);
|
uint32_t new_state = *state;
|
||||||
|
|
||||||
if (new_state != data->pm_state) {
|
if (new_state != data->pm_state) {
|
||||||
uarte_nrfx_set_power_state(dev, new_state);
|
uarte_nrfx_set_power_state(dev, new_state);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
__ASSERT_NO_MSG(ctrl_command == PM_DEVICE_STATE_GET);
|
__ASSERT_NO_MSG(ctrl_command == PM_DEVICE_STATE_GET);
|
||||||
*((uint32_t *)context) = data->pm_state;
|
*state = data->pm_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cb) {
|
if (cb) {
|
||||||
cb(dev, 0, context, arg);
|
cb(dev, 0, state, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -1461,24 +1461,24 @@ static int uart_stm32_set_power_state(const struct device *dev,
|
||||||
*/
|
*/
|
||||||
static int uart_stm32_pm_control(const struct device *dev,
|
static int uart_stm32_pm_control(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
void *context, pm_device_cb cb,
|
uint32_t *state, pm_device_cb cb,
|
||||||
void *arg)
|
void *arg)
|
||||||
{
|
{
|
||||||
struct uart_stm32_data *data = DEV_DATA(dev);
|
struct uart_stm32_data *data = DEV_DATA(dev);
|
||||||
|
|
||||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
||||||
uint32_t new_state = *((const uint32_t *)context);
|
uint32_t new_state = *state;
|
||||||
|
|
||||||
if (new_state != data->pm_state) {
|
if (new_state != data->pm_state) {
|
||||||
uart_stm32_set_power_state(dev, new_state);
|
uart_stm32_set_power_state(dev, new_state);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
__ASSERT_NO_MSG(ctrl_command == PM_DEVICE_STATE_GET);
|
__ASSERT_NO_MSG(ctrl_command == PM_DEVICE_STATE_GET);
|
||||||
*((uint32_t *)context) = data->pm_state;
|
*state = data->pm_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cb) {
|
if (cb) {
|
||||||
cb(dev, 0, context, arg);
|
cb(dev, 0, state, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -251,13 +251,13 @@ 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,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
void *context, pm_device_cb cb,
|
uint32_t *state, pm_device_cb cb,
|
||||||
void *arg)
|
void *arg)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
||||||
uint32_t new_state = *((const uint32_t *)context);
|
uint32_t new_state = *state;
|
||||||
|
|
||||||
if (new_state != get_dev_data(dev)->pm_state) {
|
if (new_state != get_dev_data(dev)->pm_state) {
|
||||||
ret = spi_cc13xx_cc26xx_set_power_state(dev,
|
ret = spi_cc13xx_cc26xx_set_power_state(dev,
|
||||||
|
@ -265,11 +265,11 @@ static int spi_cc13xx_cc26xx_pm_control(const struct device *dev,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
__ASSERT_NO_MSG(ctrl_command == PM_DEVICE_STATE_GET);
|
__ASSERT_NO_MSG(ctrl_command == PM_DEVICE_STATE_GET);
|
||||||
*((uint32_t *)context) = get_dev_data(dev)->pm_state;
|
*state = get_dev_data(dev)->pm_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cb) {
|
if (cb) {
|
||||||
cb(dev, ret, context, arg);
|
cb(dev, ret, state, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -286,14 +286,14 @@ 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,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
void *context, pm_device_cb cb, void *arg)
|
uint32_t *state, pm_device_cb cb, void *arg)
|
||||||
{
|
{
|
||||||
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) {
|
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
||||||
uint32_t new_state = *((const uint32_t *)context);
|
uint32_t new_state = *state;
|
||||||
|
|
||||||
if (new_state != data->pm_state) {
|
if (new_state != data->pm_state) {
|
||||||
switch (new_state) {
|
switch (new_state) {
|
||||||
|
@ -320,11 +320,11 @@ static int spi_nrfx_pm_control(const struct device *dev,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
__ASSERT_NO_MSG(ctrl_command == PM_DEVICE_STATE_GET);
|
__ASSERT_NO_MSG(ctrl_command == PM_DEVICE_STATE_GET);
|
||||||
*((uint32_t *)context) = data->pm_state;
|
*state = data->pm_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cb) {
|
if (cb) {
|
||||||
cb(dev, ret, context, arg);
|
cb(dev, ret, state, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -334,14 +334,14 @@ 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,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
void *context, pm_device_cb cb, void *arg)
|
uint32_t *state, pm_device_cb cb, void *arg)
|
||||||
{
|
{
|
||||||
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) {
|
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
||||||
uint32_t new_state = *((const uint32_t *)context);
|
uint32_t new_state = *state;
|
||||||
|
|
||||||
if (new_state != data->pm_state) {
|
if (new_state != data->pm_state) {
|
||||||
switch (new_state) {
|
switch (new_state) {
|
||||||
|
@ -368,11 +368,11 @@ static int spim_nrfx_pm_control(const struct device *dev,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
__ASSERT_NO_MSG(ctrl_command == PM_DEVICE_STATE_GET);
|
__ASSERT_NO_MSG(ctrl_command == PM_DEVICE_STATE_GET);
|
||||||
*((uint32_t *)context) = data->pm_state;
|
*state = data->pm_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cb) {
|
if (cb) {
|
||||||
cb(dev, ret, context, arg);
|
cb(dev, ret, state, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -32,7 +32,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,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
void *context, pm_device_cb cb, void *arg)
|
uint32_t *context, pm_device_cb cb, void *arg)
|
||||||
{
|
{
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
}
|
}
|
||||||
|
|
|
@ -387,7 +387,7 @@ struct device {
|
||||||
#ifdef CONFIG_PM_DEVICE
|
#ifdef CONFIG_PM_DEVICE
|
||||||
/** Power Management function */
|
/** Power Management function */
|
||||||
int (*pm_control)(const struct device *dev, uint32_t command,
|
int (*pm_control)(const struct device *dev, uint32_t command,
|
||||||
void *context, pm_device_cb cb, void *arg);
|
uint32_t *state, pm_device_cb cb, void *arg);
|
||||||
/** 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
|
||||||
|
|
|
@ -78,7 +78,7 @@ struct device;
|
||||||
#define PM_DEVICE_STATE_GET 2
|
#define PM_DEVICE_STATE_GET 2
|
||||||
|
|
||||||
typedef void (*pm_device_cb)(const struct device *dev,
|
typedef void (*pm_device_cb)(const struct device *dev,
|
||||||
int status, void *context, void *arg);
|
int status, uint32_t *state, void *arg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Device PM info
|
* @brief Device PM info
|
||||||
|
|
|
@ -117,27 +117,27 @@ static int dummy_resume_from_suspend(const struct device *dev)
|
||||||
|
|
||||||
static int dummy_device_pm_ctrl(const struct device *dev,
|
static int dummy_device_pm_ctrl(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
void *context, pm_device_cb cb, void *arg)
|
uint32_t *state, pm_device_cb cb, void *arg)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
switch (ctrl_command) {
|
switch (ctrl_command) {
|
||||||
case PM_DEVICE_STATE_SET:
|
case PM_DEVICE_STATE_SET:
|
||||||
if (*((uint32_t *)context) == PM_DEVICE_ACTIVE_STATE) {
|
if (*state == PM_DEVICE_ACTIVE_STATE) {
|
||||||
ret = dummy_resume_from_suspend(dev);
|
ret = dummy_resume_from_suspend(dev);
|
||||||
} else {
|
} else {
|
||||||
ret = dummy_suspend(dev);
|
ret = dummy_suspend(dev);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PM_DEVICE_STATE_GET:
|
case PM_DEVICE_STATE_GET:
|
||||||
*((uint32_t *)context) = dummy_get_power_state(dev);
|
*state = dummy_get_power_state(dev);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cb(dev, ret, context, arg);
|
cb(dev, ret, state, arg);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,27 +48,27 @@ static int dummy_resume_from_suspend(const struct device *dev)
|
||||||
|
|
||||||
static int dummy_parent_pm_ctrl(const struct device *dev,
|
static int dummy_parent_pm_ctrl(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
void *context, pm_device_cb cb, void *arg)
|
uint32_t *state, pm_device_cb cb, void *arg)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
switch (ctrl_command) {
|
switch (ctrl_command) {
|
||||||
case PM_DEVICE_STATE_SET:
|
case PM_DEVICE_STATE_SET:
|
||||||
if (*((uint32_t *)context) == PM_DEVICE_ACTIVE_STATE) {
|
if (*state == PM_DEVICE_ACTIVE_STATE) {
|
||||||
ret = dummy_resume_from_suspend(dev);
|
ret = dummy_resume_from_suspend(dev);
|
||||||
} else {
|
} else {
|
||||||
ret = dummy_suspend(dev);
|
ret = dummy_suspend(dev);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PM_DEVICE_STATE_GET:
|
case PM_DEVICE_STATE_GET:
|
||||||
*((uint32_t *)context) = dummy_get_power_state(dev);
|
*state = dummy_get_power_state(dev);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cb(dev, ret, context, arg);
|
cb(dev, ret, state, arg);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,12 +27,12 @@ enum device_pm_state {
|
||||||
#define PM_DEVICE_ASYNC (1 << 0)
|
#define PM_DEVICE_ASYNC (1 << 0)
|
||||||
|
|
||||||
static void device_pm_callback(const struct device *dev,
|
static void device_pm_callback(const struct device *dev,
|
||||||
int retval, void *context, void *arg)
|
int retval, uint32_t *state, void *arg)
|
||||||
{
|
{
|
||||||
__ASSERT(retval == 0, "Device set power state failed");
|
__ASSERT(retval == 0, "Device set power state failed");
|
||||||
|
|
||||||
/* Set the fsm_state */
|
/* Set the fsm_state */
|
||||||
if (*((uint32_t *)context) == PM_DEVICE_ACTIVE_STATE) {
|
if (*state == PM_DEVICE_ACTIVE_STATE) {
|
||||||
atomic_set(&dev->pm->fsm_state,
|
atomic_set(&dev->pm->fsm_state,
|
||||||
PM_DEVICE_STATE_ACTIVE);
|
PM_DEVICE_STATE_ACTIVE);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -22,18 +22,18 @@ struct fake_dev_context {
|
||||||
};
|
};
|
||||||
|
|
||||||
static int fake_dev_pm_control(const struct device *dev, uint32_t command,
|
static int fake_dev_pm_control(const struct device *dev, uint32_t command,
|
||||||
void *context, pm_device_cb cb, void *arg)
|
uint32_t *state, pm_device_cb cb, void *arg)
|
||||||
{
|
{
|
||||||
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 (command == PM_DEVICE_STATE_SET) {
|
||||||
if (*(uint32_t *)context == PM_DEVICE_SUSPEND_STATE) {
|
if (*state == PM_DEVICE_SUSPEND_STATE) {
|
||||||
ret = net_if_suspend(ctx->iface);
|
ret = net_if_suspend(ctx->iface);
|
||||||
if (ret == -EBUSY) {
|
if (ret == -EBUSY) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
} else if (*(uint32_t *)context == PM_DEVICE_ACTIVE_STATE) {
|
} else if (*state == PM_DEVICE_ACTIVE_STATE) {
|
||||||
ret = net_if_resume(ctx->iface);
|
ret = net_if_resume(ctx->iface);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -42,7 +42,7 @@ static int fake_dev_pm_control(const struct device *dev, uint32_t command,
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (cb) {
|
if (cb) {
|
||||||
cb(dev, ret, context, arg);
|
cb(dev, ret, state, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -40,20 +40,20 @@ static int dummy_resume_from_suspend(const struct device *dev)
|
||||||
|
|
||||||
static int dummy_device_pm_ctrl(const struct device *dev,
|
static int dummy_device_pm_ctrl(const struct device *dev,
|
||||||
uint32_t ctrl_command,
|
uint32_t ctrl_command,
|
||||||
void *context, pm_device_cb cb, void *arg)
|
uint32_t *state, pm_device_cb cb, void *arg)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
switch (ctrl_command) {
|
switch (ctrl_command) {
|
||||||
case PM_DEVICE_STATE_SET:
|
case PM_DEVICE_STATE_SET:
|
||||||
if (*((uint32_t *)context) == PM_DEVICE_ACTIVE_STATE) {
|
if (*state == PM_DEVICE_ACTIVE_STATE) {
|
||||||
ret = dummy_resume_from_suspend(dev);
|
ret = dummy_resume_from_suspend(dev);
|
||||||
} else {
|
} else {
|
||||||
ret = dummy_suspend(dev);
|
ret = dummy_suspend(dev);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PM_DEVICE_STATE_GET:
|
case PM_DEVICE_STATE_GET:
|
||||||
*((uint32_t *)context) = dummy_get_power_state(dev);
|
*state = dummy_get_power_state(dev);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
|
@ -61,7 +61,7 @@ static int dummy_device_pm_ctrl(const struct device *dev,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cb) {
|
if (cb) {
|
||||||
cb(dev, ret, context, arg);
|
cb(dev, ret, state, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue