From: TaeminYeom Date: Mon, 12 Dec 2022 09:05:12 +0000 (+0900) Subject: power: Add "DEVICE" or "device" prefix to enum and API X-Git-Tag: accepted/tizen/unified/20221220.180315~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0adc137f91bfe4b6e170df8607f4d1778ac38e64;p=platform%2Fcore%2Fsystem%2Fdeviced.git power: Add "DEVICE" or "device" prefix to enum and API To prevent collision, it is a principle to attach a prefix of project name in capi project. However, previous codes does not meet it. So, there is a patch in capi-system-device, and also change the code using them in deviced. changed enum: power_state_e -> device_power_state_e POWER_STATE_* -> DEVICE_POWER_STATE_* power_transient_state_e -> device_power_transient_state_e POWER_STATE_TRANSIENT_* -> DEVICE_POWER_STATE_TRANSIENT_* POWER_STATE_TRANSIENT_*_EARLY -> DEVICE_POWER_STATE_TRANSIENT_*_EARLY POWER_STATE_TRANSIENT_*_LATE -> DEVICE_POWER_STATE_TRANSIENT_*_LATE POWER_STATE_*_INDEX -> DEVICE_POWER_STATE_*_INDEX POWER_STATE_TRANSIENT_*_INDEX -> DEVICE_POWER_STATE_TRANSIENT_*_INDEX changed callback: power_change_state_wait_callback -> device_power_change_state_wait_callback Change-Id: I38887a0c35f897af2607b4ddf1e167675c1daf72 Signed-off-by: TaeminYeom --- diff --git a/src/battery/lowbat-handler.c b/src/battery/lowbat-handler.c index 2584b25..85ccd4d 100644 --- a/src/battery/lowbat-handler.c +++ b/src/battery/lowbat-handler.c @@ -239,7 +239,7 @@ direct_launch: if (launched_poweroff == 1) { _I("Will be foreced power off."); - power_execute(POWER_STATE_POWEROFF); + power_execute(DEVICE_POWER_STATE_POWEROFF); return 0; } @@ -293,7 +293,7 @@ static int battery_critical_low_act(void *data) static int battery_power_off_act(void *data) { CRITICAL_LOG("Low battery power off."); - return power_execute(POWER_STATE_POWEROFF); + return power_execute(DEVICE_POWER_STATE_POWEROFF); } int battery_charge_err_cf_act(void *data) diff --git a/src/power/power-boot.c b/src/power/power-boot.c index 75ed8db..7814edb 100644 --- a/src/power/power-boot.c +++ b/src/power/power-boot.c @@ -177,7 +177,7 @@ void initial_transition_by_boot_condition(void) retval = hal_device_board_get_boot_reason(bc.reason, sizeof(bc.reason)); if (retval != 0) { _I("Failed to get BootReason, %d. Default change state to normal.", retval); - power_request_change_state_strict(POWER_STATE_START, POWER_STATE_NORMAL, 1, NULL); + power_request_change_state_strict(DEVICE_POWER_STATE_START, DEVICE_POWER_STATE_NORMAL, 1, NULL); return; } diff --git a/src/power/power-dbus.c b/src/power/power-dbus.c index 89162cc..b735121 100644 --- a/src/power/power-dbus.c +++ b/src/power/power-dbus.c @@ -298,11 +298,11 @@ static GVariant *dbus_power_change_state(GDBusConnection *conn, g_variant_get(param, "(t)", &next); - for (index = POWER_STATE_MIN_INDEX; index < POWER_STATE_MAX_INDEX; ++index) + for (index = DEVICE_POWER_STATE_MIN_INDEX; index < DEVICE_POWER_STATE_MAX_INDEX; ++index) if (next == (1UL << index)) break; - if (index == POWER_STATE_MAX_INDEX) { + if (index == DEVICE_POWER_STATE_MAX_INDEX) { _E("Invalid next state=%#lx", (long) index); ret = -EINVAL; goto out; @@ -320,7 +320,7 @@ static GVariant *dbus_power_change_state(GDBusConnection *conn, _I("Pid=%d(%s) sent request for PowerChangeState to %s", pid, comm, state_name(next)); - power_request_change_state_strict(POWER_STATE_ALL, next, 0, NULL); + power_request_change_state_strict(DEVICE_POWER_STATE_ALL, next, 0, NULL); out: return g_variant_new("(i)", ret); diff --git a/src/power/power-off.c b/src/power/power-off.c index 2cf17c6..77059fe 100644 --- a/src/power/power-off.c +++ b/src/power/power-off.c @@ -138,11 +138,11 @@ void poweroff_request_shutdown(int state) if (!is_poweroff_state(state)) return; - if (state == POWER_STATE_POWEROFF) + if (state == DEVICE_POWER_STATE_POWEROFF) systemd_method = "PowerOff"; - else if (state == POWER_STATE_REBOOT) + else if (state == DEVICE_POWER_STATE_REBOOT) systemd_method = "Reboot"; - else if (state == POWER_STATE_EXIT) + else if (state == DEVICE_POWER_STATE_EXIT) systemd_method = "Exit"; CRITICAL_LOG("Requested %s via systemd.", systemd_method); @@ -191,18 +191,18 @@ static void poweroff_delay_for_seconds(void) int poweroff_check_revived(void) { if (access(POWEROFF_OPTPATH_POWEROFF, F_OK) == 0) { - return POWER_STATE_POWEROFF; + return DEVICE_POWER_STATE_POWEROFF; } if (access(POWEROFF_OPTPATH_REBOOT, F_OK) == 0) { - return POWER_STATE_REBOOT; + return DEVICE_POWER_STATE_REBOOT; } if (access(POWEROFF_OPTPATH_EXIT, F_OK) == 0) { - return POWER_STATE_EXIT; + return DEVICE_POWER_STATE_EXIT; } - return POWER_STATE_NORMAL; + return DEVICE_POWER_STATE_NORMAL; } static void mark_poweroff_option(uint64_t state, const char *option) @@ -211,11 +211,11 @@ static void mark_poweroff_option(uint64_t state, const char *option) ssize_t len; const char *optpath; - if (state == POWER_STATE_POWEROFF) + if (state == DEVICE_POWER_STATE_POWEROFF) optpath = POWEROFF_OPTPATH_POWEROFF; - else if (state == POWER_STATE_REBOOT) + else if (state == DEVICE_POWER_STATE_REBOOT) optpath = POWEROFF_OPTPATH_REBOOT; - else if (state == POWER_STATE_EXIT) + else if (state == DEVICE_POWER_STATE_EXIT) optpath = POWEROFF_OPTPATH_EXIT; else return; @@ -300,9 +300,9 @@ void poweroff_prepare(uint64_t state, void *option) mark_poweroff_option(state, option); - if (state == POWER_STATE_POWEROFF) + if (state == DEVICE_POWER_STATE_POWEROFF) vconf = VCONFKEY_SYSMAN_POWER_OFF_DIRECT; - else if (state == POWER_STATE_REBOOT) + else if (state == DEVICE_POWER_STATE_REBOOT) vconf = VCONFKEY_SYSMAN_POWER_OFF_RESTART; vconf_set_int(VCONFKEY_SYSMAN_POWER_OFF_STATUS, vconf); @@ -355,18 +355,18 @@ static GVariant *dbus_poweroff_handler(GDBusConnection *conn, get_command(ret, comm, sizeof(comm)); if (strncmp(type, "poweroff", sizeof("poweroff")) == 0) - next = POWER_STATE_POWEROFF; + next = DEVICE_POWER_STATE_POWEROFF; else if (strncmp(type, "reboot", sizeof("reboot")) == 0) - next = POWER_STATE_REBOOT; + next = DEVICE_POWER_STATE_REBOOT; else if (strncmp(type, "exit", sizeof("exit")) == 0) - next = POWER_STATE_EXIT; + next = DEVICE_POWER_STATE_EXIT; else { ret = -EINVAL; goto out; } CRITICAL_LOG("Poweroff pid=%d(%s) requests %s.", ret, comm, type); - power_request_change_state_strict(POWER_STATE_ALL, next, 9000, NULL); + power_request_change_state_strict(DEVICE_POWER_STATE_ALL, next, 9000, NULL); out: g_free(type); @@ -391,18 +391,18 @@ static GVariant *dbus_poweroff_option_handler(GDBusConnection *conn, get_command(ret, comm, sizeof(comm)); if (strncmp(type, "poweroff", sizeof("poweroff")) == 0) - next = POWER_STATE_POWEROFF; + next = DEVICE_POWER_STATE_POWEROFF; else if (strncmp(type, "reboot", sizeof("reboot")) == 0) - next = POWER_STATE_REBOOT; + next = DEVICE_POWER_STATE_REBOOT; else if (strncmp(type, "exit", sizeof("exit")) == 0) - next = POWER_STATE_EXIT; + next = DEVICE_POWER_STATE_EXIT; else { ret = -EINVAL; goto out; } CRITICAL_LOG("Poweroff pid=%d(%s) requests type=%s option=%s.", ret, comm, type, option); - power_request_change_state_strict(POWER_STATE_ALL, next, 9000, option); + power_request_change_state_strict(DEVICE_POWER_STATE_ALL, next, 9000, option); out: g_free(type); diff --git a/src/power/power.c b/src/power/power.c index e9b2a02..47587b0 100644 --- a/src/power/power.c +++ b/src/power/power.c @@ -42,7 +42,7 @@ #define MAX_DESC_LEN 256 static int delayed_init_done = 0; -static uint64_t current = POWER_STATE_START; /* current power state */ +static uint64_t current = DEVICE_POWER_STATE_START; /* current power state */ static int max_wait_timeout = DEFAULT_MAX_WAIT_SECOND; static GQueue *transition_queue; static struct { @@ -68,26 +68,26 @@ struct change_state_wait { }; static const uint64_t transient_scenario_suspending[] = { - POWER_STATE_TRANSIENT_SUSPENDING_EARLY, - POWER_STATE_TRANSIENT_SUSPENDING, - POWER_STATE_TRANSIENT_SUSPENDING_LATE, + DEVICE_POWER_STATE_TRANSIENT_SUSPENDING_EARLY, + DEVICE_POWER_STATE_TRANSIENT_SUSPENDING, + DEVICE_POWER_STATE_TRANSIENT_SUSPENDING_LATE, }; static const uint64_t transient_scenario_resuming[] = { - POWER_STATE_TRANSIENT_RESUMING_EARLY, - POWER_STATE_TRANSIENT_RESUMING, - POWER_STATE_TRANSIENT_RESUMING_LATE, + DEVICE_POWER_STATE_TRANSIENT_RESUMING_EARLY, + DEVICE_POWER_STATE_TRANSIENT_RESUMING, + DEVICE_POWER_STATE_TRANSIENT_RESUMING_LATE, }; static const struct { int max_step; const uint64_t *scenario; -} transient[POWER_STATE_MAX_INDEX][POWER_STATE_MAX_INDEX] = { - [POWER_STATE_NORMAL_INDEX][POWER_STATE_SLEEP_INDEX] = { +} transient[DEVICE_POWER_STATE_MAX_INDEX][DEVICE_POWER_STATE_MAX_INDEX] = { + [DEVICE_POWER_STATE_NORMAL_INDEX][DEVICE_POWER_STATE_SLEEP_INDEX] = { .max_step = ARRAY_SIZE(transient_scenario_suspending), .scenario = transient_scenario_suspending, }, - [POWER_STATE_SLEEP_INDEX][POWER_STATE_NORMAL_INDEX] = { + [DEVICE_POWER_STATE_SLEEP_INDEX][DEVICE_POWER_STATE_NORMAL_INDEX] = { .max_step = ARRAY_SIZE(transient_scenario_resuming), .scenario = transient_scenario_resuming, }, @@ -101,12 +101,12 @@ 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[POWER_STATE_MAX_INDEX]) (void *) = { - [POWER_STATE_NORMAL_INDEX] = power_action_normal, - [POWER_STATE_SLEEP_INDEX] = power_action_sleep, - [POWER_STATE_POWEROFF_INDEX] = power_action_poweroff, - [POWER_STATE_REBOOT_INDEX] = power_action_poweroff, - [POWER_STATE_EXIT_INDEX] = power_action_poweroff, +static void (*const action_on_state[DEVICE_POWER_STATE_MAX_INDEX]) (void *) = { + [DEVICE_POWER_STATE_NORMAL_INDEX] = power_action_normal, + [DEVICE_POWER_STATE_SLEEP_INDEX] = power_action_sleep, + [DEVICE_POWER_STATE_POWEROFF_INDEX] = power_action_poweroff, + [DEVICE_POWER_STATE_REBOOT_INDEX] = power_action_poweroff, + [DEVICE_POWER_STATE_EXIT_INDEX] = power_action_poweroff, }; uint64_t power_get_state(void) @@ -261,8 +261,8 @@ static void power_action_normal(void *udata) static void power_action_sleep(void *udata) { - /* for POWER_STATE_NORMAL, POWER_STATE_POWEROFF, do not wake unlock */ - if (current != POWER_STATE_SLEEP) { + /* for DEVICE_POWER_STATE_NORMAL, DEVICE_POWER_STATE_POWEROFF, do not wake unlock */ + if (current != DEVICE_POWER_STATE_SLEEP) { _E("Ignore sleep wait done, current=%s", state_name(current)); return; } @@ -285,29 +285,29 @@ static void broadcast_transition_info(void) uint64_t next = get_next_state(); - if (next == POWER_STATE_START) + if (next == DEVICE_POWER_STATE_START) signame = DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_START; - else if (next == POWER_STATE_NORMAL) + else if (next == DEVICE_POWER_STATE_NORMAL) signame = DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_NORMAL; - else if (next == POWER_STATE_SLEEP) + else if (next == DEVICE_POWER_STATE_SLEEP) signame = DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_SLEEP; - else if (next == POWER_STATE_POWEROFF) + else if (next == DEVICE_POWER_STATE_POWEROFF) signame = DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_POWEROFF; - else if (next == POWER_STATE_REBOOT) + else if (next == DEVICE_POWER_STATE_REBOOT) signame = DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_REBOOT; - else if (next == POWER_STATE_EXIT) + else if (next == DEVICE_POWER_STATE_EXIT) signame = DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_EXIT; - else if (next == POWER_STATE_TRANSIENT_SUSPENDING_EARLY) + else if (next == DEVICE_POWER_STATE_TRANSIENT_SUSPENDING_EARLY) signame = DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_SUSPENDING_EARLY; - else if (next == POWER_STATE_TRANSIENT_SUSPENDING) + else if (next == DEVICE_POWER_STATE_TRANSIENT_SUSPENDING) signame = DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_SUSPENDING; - else if (next == POWER_STATE_TRANSIENT_SUSPENDING_LATE) + else if (next == DEVICE_POWER_STATE_TRANSIENT_SUSPENDING_LATE) signame = DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_SUSPENDING_LATE; - else if (next == POWER_STATE_TRANSIENT_RESUMING_EARLY) + else if (next == DEVICE_POWER_STATE_TRANSIENT_RESUMING_EARLY) signame = DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_RESUMING_EARLY; - else if (next == POWER_STATE_TRANSIENT_RESUMING) + else if (next == DEVICE_POWER_STATE_TRANSIENT_RESUMING) signame = DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_RESUMING; - else if (next == POWER_STATE_TRANSIENT_RESUMING_LATE) + else if (next == DEVICE_POWER_STATE_TRANSIENT_RESUMING_LATE) signame = DEVICED_SIGNAL_POWER_CHANGE_STATE_TO_RESUMING_LATE; else return; @@ -416,29 +416,29 @@ static void init_waiting_list(gpointer data, gpointer udata) static char *state_abbr_name(uint64_t state) { - if (state == POWER_STATE_START) + if (state == DEVICE_POWER_STATE_START) return "START"; - if (state == POWER_STATE_NORMAL) + if (state == DEVICE_POWER_STATE_NORMAL) return "NORMAL"; - if (state == POWER_STATE_SLEEP) + if (state == DEVICE_POWER_STATE_SLEEP) return "SLEEP"; - if (state == POWER_STATE_POWEROFF) + if (state == DEVICE_POWER_STATE_POWEROFF) return "POWEROFF"; - if (state == POWER_STATE_REBOOT) + if (state == DEVICE_POWER_STATE_REBOOT) return "REBOOT"; - if (state == POWER_STATE_EXIT) + if (state == DEVICE_POWER_STATE_EXIT) return "EXIT"; - if (state == POWER_STATE_TRANSIENT_SUSPENDING_EARLY) + if (state == DEVICE_POWER_STATE_TRANSIENT_SUSPENDING_EARLY) return "SUSPENDING_EARLY"; - if (state == POWER_STATE_TRANSIENT_SUSPENDING) + if (state == DEVICE_POWER_STATE_TRANSIENT_SUSPENDING) return "SUSPENDING"; - if (state == POWER_STATE_TRANSIENT_SUSPENDING_LATE) + if (state == DEVICE_POWER_STATE_TRANSIENT_SUSPENDING_LATE) return "SUSPENDING_LATE"; - if (state == POWER_STATE_TRANSIENT_RESUMING_EARLY) + if (state == DEVICE_POWER_STATE_TRANSIENT_RESUMING_EARLY) return "RESUMING_EARLY"; - if (state == POWER_STATE_TRANSIENT_RESUMING) + if (state == DEVICE_POWER_STATE_TRANSIENT_RESUMING) return "RESUMING"; - if (state == POWER_STATE_TRANSIENT_RESUMING_LATE) + if (state == DEVICE_POWER_STATE_TRANSIENT_RESUMING_LATE) return "RESUMING_LATE"; return "INVALID"; @@ -633,7 +633,7 @@ static int transition_request_callback(void *data) t = l->data; // check invalid next state - if (__builtin_popcountll(t->next & POWER_STATE_ALL) != 1) { + if (__builtin_popcountll(t->next & DEVICE_POWER_STATE_ALL) != 1) { _E("Invalid next state, curr=%"PRIx64", next=%"PRIx64", reason=%d", t->curr, t->next, t->reason); return 0; } @@ -709,8 +709,8 @@ void power_state_init(void *data) /* Take the first transition. * - * It is determined by bootreason and bootmode to which state to transition, POWER_STATE_NORMAL - * or POWER_STATE_SLEEP. it may stay in POWER_STATE_START if there is no defined action for the + * It is determined by bootreason and bootmode to which state to transition, DEVICE_POWER_STATE_NORMAL + * or DEVICE_POWER_STATE_SLEEP. it may stay in DEVICE_POWER_STATE_START if there is no defined action for the * matching bootreason and bootmode. */ initial_transition_by_boot_condition(); diff --git a/src/power/power.h b/src/power/power.h index 7771556..f559826 100644 --- a/src/power/power.h +++ b/src/power/power.h @@ -41,19 +41,19 @@ void power_state_manager_init(void *data); static inline uint64_t convert_action_string_to_power_state(const char *str) { if (MATCH(str, "start")) - return POWER_STATE_START; + return DEVICE_POWER_STATE_START; else if (MATCH(str, "sleep")) - return POWER_STATE_SLEEP; + return DEVICE_POWER_STATE_SLEEP; else if (MATCH(str, "normal")) - return POWER_STATE_NORMAL; + return DEVICE_POWER_STATE_NORMAL; else if (MATCH(str, "poweroff")) - return POWER_STATE_POWEROFF; + return DEVICE_POWER_STATE_POWEROFF; else if (MATCH(str, "reboot")) - return POWER_STATE_REBOOT; + return DEVICE_POWER_STATE_REBOOT; else if (MATCH(str, "exit")) - return POWER_STATE_EXIT; + return DEVICE_POWER_STATE_EXIT; else if (MATCH(str, "current")) - return POWER_STATE_ALL; + return DEVICE_POWER_STATE_ALL; _W("Invalid power state=%s", str); @@ -62,31 +62,31 @@ static inline uint64_t convert_action_string_to_power_state(const char *str) static inline const char *state_name(uint64_t state) { - if (state == POWER_STATE_START) + if (state == DEVICE_POWER_STATE_START) return "POWER_STATE_START"; - if (state == POWER_STATE_NORMAL) + if (state == DEVICE_POWER_STATE_NORMAL) return "POWER_STATE_NORMAL"; - if (state == POWER_STATE_SLEEP) + if (state == DEVICE_POWER_STATE_SLEEP) return "POWER_STATE_SLEEP"; - if (state == POWER_STATE_POWEROFF) + if (state == DEVICE_POWER_STATE_POWEROFF) return "POWER_STATE_POWEROFF"; - if (state == POWER_STATE_REBOOT) + if (state == DEVICE_POWER_STATE_REBOOT) return "POWER_STATE_REBOOT"; - if (state == POWER_STATE_EXIT) + if (state == DEVICE_POWER_STATE_EXIT) return "POWER_STATE_EXIT"; - if (state == POWER_STATE_TRANSIENT_SUSPENDING_EARLY) + if (state == DEVICE_POWER_STATE_TRANSIENT_SUSPENDING_EARLY) return "POWER_STATE_TRANSIENT_SUSPENDING_EARLY"; - if (state == POWER_STATE_TRANSIENT_SUSPENDING) + if (state == DEVICE_POWER_STATE_TRANSIENT_SUSPENDING) return "POWER_STATE_TRANSIENT_SUSPENDING"; - if (state == POWER_STATE_TRANSIENT_SUSPENDING_LATE) + if (state == DEVICE_POWER_STATE_TRANSIENT_SUSPENDING_LATE) return "POWER_STATE_TRANSIENT_SUSPENDING_LATE"; - if (state == POWER_STATE_TRANSIENT_RESUMING_EARLY) + if (state == DEVICE_POWER_STATE_TRANSIENT_RESUMING_EARLY) return "POWER_STATE_TRANSIENT_RESUMING_EARLY"; - if (state == POWER_STATE_TRANSIENT_RESUMING) + if (state == DEVICE_POWER_STATE_TRANSIENT_RESUMING) return "POWER_STATE_TRANSIENT_RESUMING"; - if (state == POWER_STATE_TRANSIENT_RESUMING_LATE) + if (state == DEVICE_POWER_STATE_TRANSIENT_RESUMING_LATE) return "POWER_STATE_TRANSIENT_RESUMING_LATE"; - if (state == POWER_STATE_ALL) + if (state == DEVICE_POWER_STATE_ALL) return "POWER_STATE_ALL"; return "POWER_STATE_INVALID"; @@ -94,7 +94,7 @@ static inline const char *state_name(uint64_t state) static inline int is_poweroff_state(uint64_t state) { - return !!(state & (POWER_STATE_POWEROFF | POWER_STATE_REBOOT | POWER_STATE_EXIT)); + return !!(state & (DEVICE_POWER_STATE_POWEROFF | DEVICE_POWER_STATE_REBOOT | DEVICE_POWER_STATE_EXIT)); } static inline void power_request_change_state_strict(uint64_t curr, uint64_t next, int reason, void *udata) @@ -107,7 +107,7 @@ static inline void power_request_change_state_strict(uint64_t curr, uint64_t nex static inline void power_request_change_state(uint64_t next, int reason) { - power_request_change_state_strict(POWER_STATE_ALL, next, reason, NULL); + power_request_change_state_strict(DEVICE_POWER_STATE_ALL, next, reason, NULL); } uint64_t power_get_state(void);