power: Rename transition_id to wait_callback_id to use consistent name 93/320493/6 accepted/tizen/unified/20241119.153843
authorChanwoo Choi <cw00.choi@samsung.com>
Sat, 16 Nov 2024 21:36:26 +0000 (06:36 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Mon, 18 Nov 2024 07:06:08 +0000 (16:06 +0900)
capi-system-device has used 'wait_callback_id' and deviced has used
'transition_id' to indicate the same value. In order to remove the
confusion of between differnet name and same thing,
rename transition_id to wait_callback_id.

Change-Id: I67790841f1568265b06384abf8e652366a0e38dc
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
src/power/power.c
src/power/power.h

index 96d35efe3eb02e6f988b0e98bd92ca1338de3467..877e05b3822389b9cc40fc654d509ce8edf049c4 100644 (file)
@@ -48,7 +48,7 @@ static uint64_t current = DEVICED_POWER_STATE_START; /* current power state */
 static int max_wait_timeout = DEFAULT_MAX_WAIT_SECOND;
 static GQueue *transition_queue;
 static struct {
-       uint64_t id;
+       uint64_t wait_callback_id;
        int ongoing;
        struct syscommon_plugin_deviced_power_trans_info ti;
        GList *waitings;
@@ -71,7 +71,7 @@ static GList *proc_list;
 
 struct change_state_wait {
        struct proc_info *pi;
-       guint64 transition_id;
+       guint64 wait_callback_id;
        int state;
 };
 
@@ -138,8 +138,8 @@ static void cleanup_waiting_list(gpointer data)
 {
        struct change_state_wait *csw = (struct change_state_wait *) data;
 
-       _E("%s(pid=%d) hasn't confirmed id=%"PRIu64"(%s)",
-               csw->pi->comm, csw->pi->pid, csw->transition_id, state_name(csw->state));
+       _E("%s(pid=%d) hasn't confirmed wait_callback_id=%"PRIu64"(%s)",
+               csw->pi->comm, csw->pi->pid, csw->wait_callback_id, state_name(csw->state));
 
        if (kill(csw->pi->pid, 0) != 0) {
                _E("cleanup not existing process: %s(pid=%d)", csw->pi->comm, csw->pi->pid);
@@ -255,16 +255,19 @@ static gint find_csw_by_pid_id(gconstpointer data, gconstpointer udata)
        const struct change_state_wait *csw = (const struct change_state_wait *) data;
        const struct change_state_wait *target = (const struct change_state_wait *) udata;
 
-       if (csw->pi->pid == target->pi->pid && csw->transition_id == target->transition_id)
+       if (csw->pi->pid == target->pi->pid && csw->wait_callback_id == target->wait_callback_id)
                return 0;
 
        return -1;
 }
 
-static int handle_change_state_wait(pid_t pid, guint64 transition_id, int transition_cancel)
+static int handle_change_state_wait(pid_t pid, guint64 wait_callback_id, int transition_cancel)
 {
        struct proc_info target_pi = { .pid = pid };
-       struct change_state_wait target_csw = { .pi = &target_pi, .transition_id = transition_id };
+       struct change_state_wait target_csw = {
+               .pi = &target_pi,
+               .wait_callback_id = wait_callback_id
+       };
        struct change_state_wait *csw = NULL;
        GList *l = NULL;
 
@@ -276,10 +279,13 @@ static int handle_change_state_wait(pid_t pid, guint64 transition_id, int transi
                return 0;
 
        csw = l->data;
-       if (transition_cancel == TRANSITION_CANCEL)
-               CRITICAL_LOG("pid=%d(%s) cancelled id=%"PRIu64"(%s)", csw->pi->pid, csw->pi->comm, csw->transition_id, state_name(csw->state));
-       else
-               _D("pid=%d(%s) confirmed id=%"PRIu64"(%s)", csw->pi->pid, csw->pi->comm, csw->transition_id, state_name(csw->state));
+       if (transition_cancel == TRANSITION_CANCEL) {
+               CRITICAL_LOG("pid=%d(%s) cancelled wait_callback_id=%"PRIu64"(%s)",
+                               csw->pi->pid, csw->pi->comm, csw->wait_callback_id, state_name(csw->state));
+       } else {
+               _D("pid=%d(%s) confirmed wait_callback_id=%"PRIu64"(%s)",
+                               csw->pi->pid, csw->pi->comm, csw->wait_callback_id, state_name(csw->state));
+       }
 
        transition_context.waitings = g_list_remove_link(transition_context.waitings, l);
        free(g_steal_pointer(&l->data));
@@ -298,20 +304,20 @@ static int handle_change_state_wait(pid_t pid, guint64 transition_id, int transi
        return 0;
 }
 
-int confirm_change_state_wait(pid_t pid, guint64 transition_id)
+int confirm_change_state_wait(pid_t pid, guint64 wait_callback_id)
 {
-       return handle_change_state_wait(pid, transition_id, TRANSITION_CONFIRM);
+       return handle_change_state_wait(pid, wait_callback_id, TRANSITION_CONFIRM);
 }
 
-int cancel_change_state_wait(pid_t pid, guint64 transition_id)
+int cancel_change_state_wait(pid_t pid, guint64 wait_callback_id)
 {
        /* do not allow cancelling poweroff transition */
        if (is_poweroff_state(transition_context.ti.next))
-               return handle_change_state_wait(pid, transition_id, TRANSITION_CONFIRM);
+               return handle_change_state_wait(pid, wait_callback_id, TRANSITION_CONFIRM);
 
        transition_context.cancel = 1;
 
-       return handle_change_state_wait(pid, transition_id, TRANSITION_CANCEL);
+       return handle_change_state_wait(pid, wait_callback_id, TRANSITION_CANCEL);
 }
 
 static uint64_t alloc_unique_id(void)
@@ -387,7 +393,7 @@ static void broadcast_transition_info(void)
                g_variant_new("(ttti)",
                        mapping_device_state[curr],
                        mapping_device_state[next],
-                       transition_context.id,
+                       transition_context.wait_callback_id,
                        transition_context.ti.reason));
 }
 
@@ -476,7 +482,7 @@ static void init_waiting_list(gpointer data, gpointer udata)
 
        *csw = (struct change_state_wait) {
                .pi = pi,
-               .transition_id = transition_context.id,
+               .wait_callback_id = transition_context.wait_callback_id,
                .state = waiting_state,
        };
 
@@ -600,7 +606,7 @@ static void trigger_transition(void)
        assert(current != DEVICED_POWER_STATE_EXIT);
        assert(transition_context.max_wait_timer == 0);
 
-       transition_context.id = alloc_unique_id();
+       transition_context.wait_callback_id = alloc_unique_id();
 
        if (!transition_context.ongoing) {
                // hold secondary wakelock not to fall asleep during transition
index 079f8a327d2255669e1986a5e3f0589e166b3eda..5dbe46fe4747fc46f7ea160450ce1abfd38bcdc7 100644 (file)
@@ -84,7 +84,7 @@ uint64_t power_get_state(void);
 int add_change_state_wait(pid_t pid, guint64 state);
 int is_there_pending_transition(void);
 void remove_change_state_wait(pid_t pid, guint64 state);
-int confirm_change_state_wait(pid_t pid, guint64 transition_id);
-int cancel_change_state_wait(pid_t pid, guint64 transition_id);
+int confirm_change_state_wait(pid_t pid, guint64 wait_callback_id);
+int cancel_change_state_wait(pid_t pid, guint64 wait_callback_id);
 
 #endif //__POWER_STATE_MANAGER_H__