summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChanwoo Choi <cw00.choi@samsung.com>2023-08-17 19:44:15 +0900
committerChanwoo Choi <cw00.choi@samsung.com>2023-08-18 10:00:39 +0900
commit913842514c326300feb34b50eba6e8e56e3b9719 (patch)
tree7149d0f47193ffd70b20039683caa10f44f78546
parent9ebe7bc5c583fe49a8d56af241ef6044c63dd286 (diff)
downloadlibsyscommon-913842514c326300feb34b50eba6e8e56e3b9719.tar.gz
libsyscommon-913842514c326300feb34b50eba6e8e56e3b9719.tar.bz2
libsyscommon-913842514c326300feb34b50eba6e8e56e3b9719.zip
plugin-api: deviced: power: Add syscommon_plugin_deviced_power_convert_to_power_state()
syscommon_plugin_deviced_power_convert_to_power_state() plugin api converts the power action string to DEVICED_POWER_STATE_* enumeration. Change-Id: I14fb07cfa64527fceba58116977b32986c14edda Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
-rw-r--r--src/plugin-api/deviced/include/syscommon-plugin-deviced-power-interface.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/plugin-api/deviced/include/syscommon-plugin-deviced-power-interface.h b/src/plugin-api/deviced/include/syscommon-plugin-deviced-power-interface.h
index 4f05328..95394c1 100644
--- a/src/plugin-api/deviced/include/syscommon-plugin-deviced-power-interface.h
+++ b/src/plugin-api/deviced/include/syscommon-plugin-deviced-power-interface.h
@@ -73,6 +73,26 @@ enum {
#define DEVICED_POWER_STATE_INDEX(state) (__builtin_ctzll(state))
+static inline u_int64_t syscommon_plugin_deviced_power_convert_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;
+}
+
#ifdef __cplusplus
}
#endif