static void action_transition(void);
static uint64_t get_next_state(void);
-static void power_action_normal(void *data);
-static void power_action_sleep(void *data);
-static void power_action_poweroff(void *data);
-static void (*const action_on_state[DEVICED_POWER_STATE_MAX_INDEX]) (void *) = {
- [DEVICED_POWER_STATE_NORMAL_INDEX] = power_action_normal,
- [DEVICED_POWER_STATE_SLEEP_INDEX] = power_action_sleep,
- [DEVICED_POWER_STATE_POWEROFF_INDEX] = power_action_poweroff,
- [DEVICED_POWER_STATE_REBOOT_INDEX] = power_action_poweroff,
- [DEVICED_POWER_STATE_EXIT_INDEX] = power_action_poweroff,
+static void action_for_normal(void *data);
+static void action_for_sleep(void *data);
+static void action_for_poweroff(void *data);
+static void (*const action_for_state[DEVICED_POWER_STATE_MAX_INDEX]) (void *) = {
+ [DEVICED_POWER_STATE_NORMAL_INDEX] = action_for_normal,
+ [DEVICED_POWER_STATE_SLEEP_INDEX] = action_for_sleep,
+ [DEVICED_POWER_STATE_POWEROFF_INDEX] = action_for_poweroff,
+ [DEVICED_POWER_STATE_REBOOT_INDEX] = action_for_poweroff,
+ [DEVICED_POWER_STATE_EXIT_INDEX] = action_for_poweroff,
};
uint64_t power_get_state(void)
return ++id;
}
-static void power_action_normal(void *udata)
+static void action_for_normal(void *udata)
{
power_resume(transition_context.ti.reason);
}
-static void power_action_sleep(void *udata)
+static void action_for_sleep(void *udata)
{
- /* for DEVICED_POWER_STATE_NORMAL, DEVICED_POWER_STATE_POWEROFF, do not wake unlock */
- if (current != DEVICED_POWER_STATE_SLEEP) {
- _E("Ignore sleep wait done, current=%s", state_name(current));
- return;
- }
-
power_suspend(transition_context.ti.reason);
}
-static void power_action_poweroff(void *data)
+static void action_for_poweroff(void *data)
{
// do not transition anymore after poweroff
unregister_notifier(DEVICE_NOTIFIER_REQUEST_TRANSITION_STATE, transition_request_callback);
int retval;
int index;
- current = transition_context.ti.next;
index = DEVICED_POWER_STATE_INDEX(transition_context.ti.next);
-
if (transition_context.cancel)
cancel_transition();
- else if (action_on_state[index])
- action_on_state[index](transition_context.ti.data);
+ else if (action_for_state[index])
+ action_for_state[index](transition_context.ti.data);
// transition end
transition_context.ongoing = 0;
+ current = transition_context.ti.next;
event_wake_unlock(EL_POWER_TRANSITION_STATE);
// trigger next transition if exist