pass: gov: Remove global variable of pmqos
authorChanwoo Choi <cw00.choi@samsung.com>
Thu, 2 Feb 2017 04:54:01 +0000 (13:54 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Thu, 2 Feb 2017 23:43:19 +0000 (08:43 +0900)
This patch removes the the global variable of pmqos. Instead, the callback
funtcion of each notifier use the 'user_data" provided by device-notifier lib.

And, this patch adds the simple description for callback function of notifier.

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

index 989af605bca6bc4165f58a5d31df307432c3a9c4..b45ee03e7f07bbe291f017550df36505f416c5ba 100644 (file)
 
 #define PASS_CPU_STATS_MAX_COUNT       20
 
-/*
- * FIXME: Current notifier of PASS didn't pass separate user_data parameter
- * on callback function. So, PASS must need global pass_policy instance. This
- * code must be modified after changing PASS's notifier feature.
- */
-static struct pass_policy *policy_pmqos[PASS_RESOURCE_MAX];
-static int num_policy_pmqos = 0;
-
 /*
  * is_enabled - Check the state of PASS governor
  * @policy: instance of pass_policy structure
@@ -58,42 +50,32 @@ static bool is_enabled(struct pass_policy *policy)
 }
 
 /*
- * pass_notifier_booting_done - Callback function of DEVICE_NOTIFIER_BOOTING_
- *                              DONE notifier
+ * pass_notifier_booting_done - Callback func of DEVICE_NOTIFIER_BOOTING_DONE
  * @data: NULL, this parameter isn't used
+ * @user_data: the instance of struct pass_policy
  */
 static int pass_notifier_booting_done(void *data, void *user_data)
 {
-       int i;
-
-       if (num_policy_pmqos == 0)
-               return 0;
+       struct pass_policy *policy = user_data;
 
        /* Start PASS governor if 'pass_support' in pass.conf is true */
-       for (i = 0; i < num_policy_pmqos; i++) {
-               if (policy_pmqos[i]->state == PASS_ON
-                       && policy_pmqos[i]->governor != NULL) {
-                       policy_pmqos[i]->governor->update(policy_pmqos[i],
-                                                       PASS_GOV_START);
-               }
-       }
+       if (policy->state == PASS_ON)
+               pass_governor_update(policy, PASS_GOV_START);
 
        return 0;
 }
 
+/*
+ * pass_notifier_pmqos - Callback func of DEVICE_NOTIFIER_PMQOS
+ * @data: the scenario name
+ * @user_data: the instance of struct pass_policy
+ */
 static int pass_notifier_pmqos(void *data, void *user_data)
 {
-       int i;
-
-       if (num_policy_pmqos == 0)
-               return 0;
+       struct pass_policy *policy = user_data;
 
-       for (i = 0; i < num_policy_pmqos; i++) {
-               if (policy_pmqos[i]->state == PASS_ON
-                       && policy_pmqos[i]->governor != NULL) {
-                       pass_notifier_pmqos_func(policy_pmqos[i], data);
-               }
-       }
+       if (policy->state == PASS_ON)
+               pass_notifier_pmqos_func(policy, data);
 
        return 0;
 }
@@ -111,14 +93,6 @@ static int pass_notifier_init(struct pass_policy *policy)
        register_notifier(DEVICE_NOTIFIER_BOOTING_DONE,
                          pass_notifier_booting_done, policy);
 
-       /*
-        * FIXME: Current notifier of PASS didn't pass separate user_data
-        * parameter on callback function. So, PASS must need global pass_policy
-        * instance. This code must be modified after changing PASS's
-        * notifier feature.
-        */
-       policy_pmqos[num_policy_pmqos++] = policy;
-
        return 0;
 }
 
@@ -571,12 +545,6 @@ static int __pass_governor_exit(struct pass_policy *policy)
        if (policy->hotplug)
                free(policy->hotplug->sequence);
 
-       if (num_policy_pmqos > 0) {
-               for (i = 0; i < num_policy_pmqos; i++)
-                       policy_pmqos[i] = NULL;
-               num_policy_pmqos = 0;
-       }
-
        /* Set pass_policy structure as default value */
        policy->pass_cpu_threshold = 0;
        policy->up_threshold = 0;