pmqos: Edit the unproper expression of pmqos data structure 92/248292/2
authorChanwoo Choi <cw00.choi@samsung.com>
Wed, 25 Nov 2020 05:43:30 +0000 (14:43 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Wed, 25 Nov 2020 06:36:14 +0000 (15:36 +0900)
The pmqos module supports the multiple h/w resources like CPU, GPU, bus
and memory. In order to express the correct meaning, edit the unproper
expression of pmqos data structure from 'pmqos_cpu' and 'pmqos_data'
and change the local variable name from 'cpu' to 'pmqos'.

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

index 7ea160f..eb40199 100644 (file)
@@ -55,7 +55,7 @@ static SystemPassPmqos *g_gdbus_instance = NULL;
  */
 static struct pmqos_scenario *g_pmqos = NULL;
 
-struct pmqos_cpu {
+struct pmqos_data {
        char name[NAME_MAX];
        int timeout;
 };
@@ -64,7 +64,7 @@ static GList *pmqos_head;
 guint g_unlock_timeout_id;
 static struct timespec unlock_timer_start_st;
 static struct timespec unlock_timer_end_st;
-static struct pmqos_cpu unlock_timer_owner = {"", 0};
+static struct pmqos_data unlock_timer_owner = {"", 0};
 
 /******************************************************
  *       PMQOS callback functions for Init/Exit       *
@@ -283,8 +283,8 @@ static gboolean pmqos_timer(gpointer data)
 
 static int compare_timeout(const void *a, const void *b)
 {
-       const struct pmqos_cpu *pmqos_a = (const struct pmqos_cpu *)a;
-       const struct pmqos_cpu *pmqos_b = (const struct pmqos_cpu *)b;
+       const struct pmqos_data *pmqos_a = (const struct pmqos_data *)a;
+       const struct pmqos_data *pmqos_b = (const struct pmqos_data *)b;
 
        if (!pmqos_a)
                return 1;
@@ -327,7 +327,7 @@ static int set_pmqos(const char *name, int val)
 static void pmqos_unlock_timeout_update(void)
 {
        GList *elem, *next;
-       struct pmqos_cpu *cpu;
+       struct pmqos_data *pmqos;
        int delta = 0;
 
        clock_gettime(CLOCK_REALTIME, &unlock_timer_end_st);
@@ -337,36 +337,36 @@ static void pmqos_unlock_timeout_update(void)
                return;
 
        for (elem = pmqos_head; elem != NULL; elem = elem->next) {
-               cpu = elem->data;
-               cpu->timeout -= delta;
+               pmqos = elem->data;
+               pmqos->timeout -= delta;
 
                /*
                 * If timeout is INT_MAX, indicatte 'mode'.
                 * Don't need to update the timeout and cancel pmqos for mode
                 * until receiving the cancel request.
                 */
-               if (cpu->timeout == INT_MAX)
+               if (pmqos->timeout == INT_MAX)
                        continue;
 
-               if (cpu->timeout < 0)
-                       cpu->timeout = 0;
-               if (cpu->timeout > 0)
+               if (pmqos->timeout < 0)
+                       pmqos->timeout = 0;
+               if (pmqos->timeout > 0)
                        continue;
 
-               /* Set cpu unlock */
-               set_pmqos(cpu->name, false);
+               /* Set pmqos unlock */
+               set_pmqos(pmqos->name, false);
        }
 
        /* Remove all the requests of which timeout are over from the list */
        elem = pmqos_head;
        while (elem != NULL) {
-               cpu = elem->data;
+               pmqos = elem->data;
                next = elem->next;
-               if (cpu->timeout <= 0) {
+               if (pmqos->timeout <= 0) {
                        pmqos_head = g_list_remove(pmqos_head,
-                                       (gconstpointer)cpu);
-                       free(cpu);
-                       cpu = NULL;
+                                       (gconstpointer)pmqos);
+                       free(pmqos);
+                       pmqos = NULL;
                }
                elem = next;
        }
@@ -380,22 +380,22 @@ static void pmqos_unlock_timeout_update(void)
 static int pmqos_cancel(const char *name)
 {
        GList *elem = NULL;
-       struct pmqos_cpu *cpu;
+       struct pmqos_data *pmqos;
 
        /* Find previous request */
        for (elem = pmqos_head; elem != NULL; elem = elem->next) {
-               cpu = elem->data;
-               if (!strcmp(cpu->name, name))
+               pmqos = elem->data;
+               if (!strcmp(pmqos->name, name))
                        break;
        }
 
        if (!elem)
                return 0;
 
-       set_pmqos(cpu->name, false);
+       set_pmqos(pmqos->name, false);
 
-       pmqos_head = g_list_remove(pmqos_head, (gconstpointer)cpu);
-       free(cpu);
+       pmqos_head = g_list_remove(pmqos_head, (gconstpointer)pmqos);
+       free(pmqos);
 
        if (strcmp(unlock_timer_owner.name, name))
                goto out;
@@ -415,7 +415,7 @@ static int pmqos_unlock_timer_start(void)
 {
        int ret;
        GList *elem;
-       struct pmqos_cpu *cpu;
+       struct pmqos_data *pmqos;
 
        if (g_unlock_timeout_id) {
                g_source_remove(g_unlock_timeout_id);
@@ -427,16 +427,16 @@ static int pmqos_unlock_timer_start(void)
                return 0;
 
        for (elem = pmqos_head; elem != NULL; elem = elem->next) {
-               cpu = elem->data;
+               pmqos = elem->data;
                /*
                 * If timeout is INT_MAX, indicate 'mode'.
                 * Don't need to add the timre for 'mode'.
                 */
-               if (cpu->timeout == INT_MAX)
+               if (pmqos->timeout == INT_MAX)
                        continue;
-               if (cpu->timeout <= 0)
+               if (pmqos->timeout <= 0)
                        continue;
-               memcpy(&unlock_timer_owner, cpu, sizeof(struct pmqos_cpu));
+               memcpy(&unlock_timer_owner, pmqos, sizeof(struct pmqos_data));
                clock_gettime(CLOCK_REALTIME, &unlock_timer_start_st);
                g_unlock_timeout_id = g_timeout_add(
                                /* FIXME: this is int to uint conversion. */
@@ -446,7 +446,7 @@ static int pmqos_unlock_timer_start(void)
                if (g_unlock_timeout_id)
                        break;
 
-               _E("fail init pmqos unlock %s %d", cpu->name, cpu->timeout);
+               _E("fail init pmqos unlock %s %d", pmqos->name, pmqos->timeout);
                return -EPERM;
        }
        return 0;
@@ -461,27 +461,27 @@ static int pmqos_unlock_timer_start(void)
 static int pmqos_request(const char *name, int val)
 {
        GList *elem;
-       struct pmqos_cpu *cpu;
+       struct pmqos_data *pmqos;
        int found = 0;
        int ret;
 
        for (elem = pmqos_head; elem != NULL; elem = elem->next) {
-               cpu = elem->data;
-               if (!strcmp(cpu->name, name)) {
-                       cpu->timeout = val;
+               pmqos = elem->data;
+               if (!strcmp(pmqos->name, name)) {
+                       pmqos->timeout = val;
                        found = 1;
                        break;
                }
        }
 
        if (!found) {
-               cpu = calloc(1, sizeof(struct pmqos_cpu));
-               if (!cpu)
+               pmqos = calloc(1, sizeof(struct pmqos_data));
+               if (!pmqos)
                        return -ENOMEM;
 
-               snprintf(cpu->name, sizeof(cpu->name), "%s", name);
-               cpu->timeout = val;
-               pmqos_head = g_list_append(pmqos_head, (gpointer)cpu);
+               snprintf(pmqos->name, sizeof(pmqos->name), "%s", name);
+               pmqos->timeout = val;
+               pmqos_head = g_list_append(pmqos_head, (gpointer)pmqos);
        }
 
        pmqos_head = g_list_sort(pmqos_head, compare_timeout);
@@ -490,12 +490,12 @@ static int pmqos_request(const char *name, int val)
        if (ret < 0)
                goto err;
 
-       set_pmqos(cpu->name, true);
+       set_pmqos(pmqos->name, true);
        return 0;
 err:
        if (!found) {
-               pmqos_head = g_list_remove(pmqos_head, (gconstpointer)cpu);
-               free(cpu);
+               pmqos_head = g_list_remove(pmqos_head, (gconstpointer)pmqos);
+               free(pmqos);
        }
 
        return ret;
@@ -564,7 +564,7 @@ static void pmqos_free(void)
 
        memset(&unlock_timer_start_st, 0, sizeof(struct timespec));
        memset(&unlock_timer_end_st, 0, sizeof(struct timespec));
-       memset(&unlock_timer_owner, 0, sizeof(struct pmqos_cpu));
+       memset(&unlock_timer_owner, 0, sizeof(struct pmqos_data));
 
        if (pmqos_head) {
                g_list_free_full(pmqos_head, free);