power: Covnert to struct syscommon_plugin_deviced_power_trans_info 74/297374/3
authorChanwoo Choi <cw00.choi@samsung.com>
Thu, 17 Aug 2023 10:55:25 +0000 (19:55 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Fri, 18 Aug 2023 00:59:29 +0000 (09:59 +0900)
struct trans_info is used on both deviced and deviced-plugin-backend.
So that move it to plugin-api-deviced in libsyscommon and then covert
from trans_info to syscommon_plugin_deviced_power_trans_info.

Change-Id: I990f9f94dc3452e59d9c9f6b0d02a2c95e7b44ce
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
plugins/iot-headless/input/input-config.c
src/power/power-boot.c
src/power/power.c
src/power/power.h

index 2e7f753..d5ddf44 100644 (file)
@@ -30,7 +30,6 @@
 #include <linux/input.h>
 
 #include "input-config.h"
-#include "power/power.h"
 
 #define INPUT_CONF_PATH    "/etc/deviced/input.conf"
 
@@ -127,10 +126,10 @@ static void parse_condition_vconf(struct input_event_unit *ieu, const char *str)
 
 static void add_action_transition_info(struct input_event_unit *ieu, char *curr, char *next)
 {
-       struct trans_info *ti = NULL;
+       struct syscommon_plugin_deviced_power_trans_info *ti = NULL;
        GList **action_list = (GList **) &(ieu->user_data);
 
-       ti = calloc(1, sizeof(struct trans_info));
+       ti = calloc(1, sizeof(struct syscommon_plugin_deviced_power_trans_info));
        if (!ti)
                return;
 
index c59edd4..7e80dd7 100644 (file)
@@ -42,7 +42,7 @@
 
 #define INIT_CONF_PATH    "/etc/deviced/init.conf"
 
-static struct trans_info init_ti = {
+static struct syscommon_plugin_deviced_power_trans_info init_ti = {
        .reason = -1,
        .curr = 0,
        .next = 0,
index b854035..94a05c2 100644 (file)
@@ -50,7 +50,7 @@ static GQueue *transition_queue;
 static struct {
        uint64_t id;
        int ongoing;
-       struct trans_info ti;
+       struct syscommon_plugin_deviced_power_trans_info ti;
        GList *waitings;
        int transient_step;
        int max_wait_timer;
@@ -106,7 +106,7 @@ static const struct {
 };
 
 static int transition_request_callback(void *data);
-static void prepare_transition(const struct trans_info *ti);
+static void prepare_transition(const struct syscommon_plugin_deviced_power_trans_info *ti);
 static void action_transition(void);
 static uint64_t get_next_state(void);
 
@@ -371,7 +371,7 @@ int is_there_pending_transition(void)
 
 static uint64_t available_starting_state(void)
 {
-       struct trans_info *ti = NULL;
+       struct syscommon_plugin_deviced_power_trans_info *ti = NULL;
 
        // If there is pending transition,
        // the available state is the last state of pendiong transitions.
@@ -386,9 +386,9 @@ static uint64_t available_starting_state(void)
        return transition_context.ongoing ? transition_context.ti.next : current;
 }
 
-static int dequeue_transition(struct trans_info *ti)
+static int dequeue_transition(struct syscommon_plugin_deviced_power_trans_info *ti)
 {
-       struct trans_info *tail = NULL;
+       struct syscommon_plugin_deviced_power_trans_info *tail = NULL;
 
        tail = g_queue_pop_tail(transition_queue);
        if (!tail)
@@ -402,20 +402,20 @@ static int dequeue_transition(struct trans_info *ti)
        return 0;
 }
 
-static void enqueue_transition(const struct trans_info *ti)
+static void enqueue_transition(const struct syscommon_plugin_deviced_power_trans_info *ti)
 {
-       struct trans_info *ti_new = NULL;
+       struct syscommon_plugin_deviced_power_trans_info *ti_new = NULL;
 
        if (!ti)
                return;
 
-       ti_new = calloc(1, sizeof(struct trans_info));
+       ti_new = calloc(1, sizeof(struct syscommon_plugin_deviced_power_trans_info));
        if (!ti_new)
                return;
 
-       memcpy(ti_new, ti, sizeof(struct trans_info));
+       memcpy(ti_new, ti, sizeof(struct syscommon_plugin_deviced_power_trans_info));
 
-       g_queue_push_head(transition_queue, memcpy(ti_new, ti, sizeof(struct trans_info)));
+       g_queue_push_head(transition_queue, memcpy(ti_new, ti, sizeof(struct syscommon_plugin_deviced_power_trans_info)));
 }
 
 // intermediate state of ongoing transition
@@ -593,10 +593,10 @@ static void trigger_transition(void)
 
 static void cancel_transition(void)
 {
-       struct trans_info *ti = NULL;
+       struct syscommon_plugin_deviced_power_trans_info *ti = NULL;
 
-       struct trans_info poweroff = { .next = DEVICED_POWER_STATE_UNDEFINED };
-       struct trans_info undo = {
+       struct syscommon_plugin_deviced_power_trans_info poweroff = { .next = DEVICED_POWER_STATE_UNDEFINED };
+       struct syscommon_plugin_deviced_power_trans_info undo = {
                .curr = transition_context.ti.next,
                .next = transition_context.ti.curr,
                /**
@@ -643,7 +643,7 @@ static void cancel_transition(void)
 static void action_transition(void)
 {
        uint64_t state = get_next_state();
-       struct trans_info ti = { 0 , };
+       struct syscommon_plugin_deviced_power_trans_info ti = { 0 , };
        int retval;
        int index;
 
@@ -688,13 +688,13 @@ trigger_next:
        }
 }
 
-static void prepare_transition(const struct trans_info *ti)
+static void prepare_transition(const struct syscommon_plugin_deviced_power_trans_info *ti)
 {
        assert(transition_context.waitings == NULL);
        assert(transition_context.max_wait_timer == 0);
 
        if (ti) {
-               transition_context.ti = (struct trans_info) {
+               transition_context.ti = (struct syscommon_plugin_deviced_power_trans_info) {
                        .curr = ti->curr,
                        .next = ti->next,
                        .reason = ti->reason,
@@ -711,7 +711,7 @@ static void prepare_transition(const struct trans_info *ti)
 
 static gint find_ti_by_state(gconstpointer data, gconstpointer udata)
 {
-       const struct trans_info *ti = (const struct trans_info *) data;
+       const struct syscommon_plugin_deviced_power_trans_info *ti = (const struct trans_info *) data;
        const uint64_t state = *(const uint64_t *) udata;
 
        if (ti->curr & state)
@@ -723,8 +723,8 @@ static gint find_ti_by_state(gconstpointer data, gconstpointer udata)
 static int transition_request_callback(void *data)
 {
        GList *ti_list, *l;
-       const struct trans_info *t = NULL;
-       struct trans_info ti = { 0 , };
+       const struct syscommon_plugin_deviced_power_trans_info *t = NULL;
+       struct syscommon_plugin_deviced_power_trans_info ti = { 0 , };
        uint64_t available;
 
        if (!data)
@@ -749,7 +749,7 @@ static int transition_request_callback(void *data)
                return 0;
        }
 
-       ti = (struct trans_info) {
+       ti = (struct syscommon_plugin_deviced_power_trans_info) {
                .curr = available,
                .next = t->next,
                .reason = t->reason,
@@ -778,7 +778,7 @@ static int transition_request_callback(void *data)
 static int delayed_init_callback(void *data)
 {
        int retval;
-       struct trans_info ti = { 0 , };
+       struct syscommon_plugin_deviced_power_trans_info ti = { 0 , };
 
        delayed_init_done = 1;
 
index 640ed43..079f8a3 100644 (file)
 
 #include "shared/device-notifier.h"
 
-struct trans_info {
-       uint64_t curr;
-       uint64_t next;
-       int reason;
-       const void *data;
-};
-
 void power_state_manager_init(void *data);
 
 static inline const char *state_name(uint64_t state)
@@ -76,7 +69,7 @@ static inline int is_poweroff_state(uint64_t state)
 
 static inline void power_request_change_state_strict(uint64_t curr, uint64_t next, int reason, const void *udata)
 {
-       struct trans_info ti = { curr, next, reason, udata };
+       struct syscommon_plugin_deviced_power_trans_info ti = { curr, next, reason, udata };
        GList l = { &ti, NULL, NULL };
 
        syscommon_notifier_emit_notify(DEVICED_NOTIFIER_REQUEST_TRANSITION_STATE, &l);