pm: use enum for device PM states
Move all PM_DEVICE_STATE_* definitions to an enum. The PM_DEVICE_STATE_SET and PM_DEVICE_STATE_GET definitions have been kept out of the enum since they do not represent any state. However, their name has not been changed since they will be removed soon. All drivers and tests have been adjusted accordingly. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
59d07b0247
commit
cc2f0e9c08
53 changed files with 214 additions and 231 deletions
|
@ -192,16 +192,17 @@ static int arc_v2_irq_unit_get_state(const struct device *dev)
|
|||
* @return operation result
|
||||
*/
|
||||
static int arc_v2_irq_unit_device_ctrl(const struct device *dev,
|
||||
uint32_t ctrl_command, uint32_t *context,
|
||||
uint32_t ctrl_command,
|
||||
enum pm_device_state *state,
|
||||
pm_device_cb cb, void *arg)
|
||||
{
|
||||
int ret = 0;
|
||||
unsigned int key = arch_irq_lock();
|
||||
|
||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
||||
if (*((uint32_t *)context) == PM_DEVICE_STATE_SUSPEND) {
|
||||
if (*state == PM_DEVICE_STATE_SUSPEND) {
|
||||
ret = arc_v2_irq_unit_suspend(dev);
|
||||
} else if (*((uint32_t *)context) == PM_DEVICE_STATE_ACTIVE) {
|
||||
} else if (*state == PM_DEVICE_STATE_ACTIVE) {
|
||||
ret = arc_v2_irq_unit_resume(dev);
|
||||
}
|
||||
} else if (ctrl_command == PM_DEVICE_STATE_GET) {
|
||||
|
|
|
@ -315,14 +315,13 @@ int ioapic_resume_from_suspend(const struct device *port)
|
|||
__pinned_func
|
||||
static int ioapic_device_ctrl(const struct device *dev,
|
||||
uint32_t ctrl_command,
|
||||
uint32_t *context, pm_device_cb cb, void *arg)
|
||||
enum pm_device_state *state,
|
||||
pm_device_cb cb, void *arg)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
||||
uint32_t new_state = *((uint32_t *)context);
|
||||
|
||||
switch (new_state) {
|
||||
switch (*state) {
|
||||
case PM_DEVICE_STATE_LOW_POWER:
|
||||
break;
|
||||
case PM_DEVICE_STATE_ACTIVE:
|
||||
|
@ -341,14 +340,14 @@ static int ioapic_device_ctrl(const struct device *dev,
|
|||
}
|
||||
|
||||
if (ret == 0) {
|
||||
ioapic_device_power_state = new_state;
|
||||
ioapic_device_power_state = *state;
|
||||
}
|
||||
} else if (ctrl_command == PM_DEVICE_STATE_GET) {
|
||||
*((uint32_t *)context) = ioapic_device_power_state;
|
||||
*state = ioapic_device_power_state;
|
||||
}
|
||||
|
||||
if (cb) {
|
||||
cb(dev, ret, context, arg);
|
||||
cb(dev, ret, state, arg);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -414,22 +414,23 @@ int loapic_resume(const struct device *port)
|
|||
__pinned_func
|
||||
static int loapic_device_ctrl(const struct device *port,
|
||||
uint32_t ctrl_command,
|
||||
uint32_t *context, pm_device_cb cb, void *arg)
|
||||
enum pm_device_state *state, pm_device_cb cb,
|
||||
void *arg)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (ctrl_command == PM_DEVICE_STATE_SET) {
|
||||
if (*context == PM_DEVICE_STATE_SUSPEND) {
|
||||
if (*state == PM_DEVICE_STATE_SUSPEND) {
|
||||
ret = loapic_suspend(port);
|
||||
} else if (*context == PM_DEVICE_STATE_ACTIVE) {
|
||||
} else if (*state == PM_DEVICE_STATE_ACTIVE) {
|
||||
ret = loapic_resume(port);
|
||||
}
|
||||
} else if (ctrl_command == PM_DEVICE_STATE_GET) {
|
||||
*context = loapic_device_power_state;
|
||||
*state = loapic_device_power_state;
|
||||
}
|
||||
|
||||
if (cb) {
|
||||
cb(port, ret, context, arg);
|
||||
cb(port, ret, state, arg);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue