From 09f9fe7a9880da182248b711d7fc97e8957d7b17 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Thu, 17 Aug 2023 19:46:28 +0900 Subject: [PATCH] power: Move convert_action_string_to_power_state() to plugin-api-deviced convert_action_string_to_power_state() is used on both deviced and deviced-plugin-backend. So that move it to plugin-api-deviced package in libsyscommon. Change-Id: I2809e7a85a51339beb673782c0aae12e8f2e3da6 Signed-off-by: Chanwoo Choi --- plugins/iot-headless/input/input-config.c | 5 +++-- src/power/power-boot.c | 5 +++-- src/power/power.h | 20 -------------------- 3 files changed, 6 insertions(+), 24 deletions(-) diff --git a/plugins/iot-headless/input/input-config.c b/plugins/iot-headless/input/input-config.c index edbcfd5..2e7f753 100644 --- a/plugins/iot-headless/input/input-config.c +++ b/plugins/iot-headless/input/input-config.c @@ -25,6 +25,7 @@ #include #include #include +#include #include @@ -137,8 +138,8 @@ static void add_action_transition_info(struct input_event_unit *ieu, char *curr, * Otherwise, ieu->id won't be defined at this point.*/ ti->reason = ieu->id; - ti->curr = convert_action_string_to_power_state(curr); - ti->next = convert_action_string_to_power_state(next); + ti->curr = syscommon_plugin_deviced_power_convert_to_power_state(curr); + ti->next = syscommon_plugin_deviced_power_convert_to_power_state(next); SYS_G_LIST_APPEND(*action_list, ti); } diff --git a/src/power/power-boot.c b/src/power/power-boot.c index 6bbceab..c59edd4 100644 --- a/src/power/power-boot.c +++ b/src/power/power-boot.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include "core/log.h" @@ -130,8 +131,8 @@ static void parse_transition_info(const char *action) char next[16] = { 0, }; if (sscanf(action, "%15[^,],%15s", curr, next) == 2) { - init_ti.curr = convert_action_string_to_power_state(curr); - init_ti.next = convert_action_string_to_power_state(next); + init_ti.curr = syscommon_plugin_deviced_power_convert_to_power_state(curr); + init_ti.next = syscommon_plugin_deviced_power_convert_to_power_state(next); } } diff --git a/src/power/power.h b/src/power/power.h index b174d5a..640ed43 100644 --- a/src/power/power.h +++ b/src/power/power.h @@ -37,26 +37,6 @@ struct trans_info { 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 DEVICED_POWER_STATE_START; - else if (MATCH(str, "sleep")) - return DEVICED_POWER_STATE_SLEEP; - else if (MATCH(str, "normal")) - return DEVICED_POWER_STATE_NORMAL; - else if (MATCH(str, "poweroff")) - return DEVICED_POWER_STATE_POWEROFF; - else if (MATCH(str, "reboot")) - return DEVICED_POWER_STATE_REBOOT; - else if (MATCH(str, "exit")) - return DEVICED_POWER_STATE_EXIT; - else if (MATCH(str, "current")) - return DEVICED_POWER_STATE_ALL; - - return DEVICED_POWER_STATE_UNDEFINED; -} - static inline const char *state_name(uint64_t state) { if (state == DEVICED_POWER_STATE_START) -- 2.7.4