]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
thermal: core: group functions related to governor handling
authorEduardo Valentin <edubezval@gmail.com>
Tue, 8 Nov 2016 05:09:05 +0000 (21:09 -0800)
committerZhang Rui <rui.zhang@intel.com>
Wed, 23 Nov 2016 02:06:12 +0000 (10:06 +0800)
Organize thermal core code to group the functions
handling with governor manipulation in one single section.

Cc: Zhang Rui <rui.zhang@intel.com>
Cc: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
drivers/thermal/thermal_core.c

index 519aa94d0837ded58cf9a0460534f9d912acf07e..e36a6a6e58dbfb2ede0fd617715b3b08f5a48d2d 100644 (file)
@@ -64,6 +64,13 @@ static atomic_t in_suspend;
 
 static struct thermal_governor *def_governor;
 
+/*
+ * Governor section: set of functions to handle thermal governors
+ *
+ * Functions to help in the life cycle of thermal governors within
+ * the thermal core and by the thermal governor code.
+ */
+
 static struct thermal_governor *__find_governor(const char *name)
 {
        struct thermal_governor *pos;
@@ -206,6 +213,79 @@ exit:
        return;
 }
 
+int thermal_zone_device_set_policy(struct thermal_zone_device *tz,
+                                  char *policy)
+{
+       struct thermal_governor *gov;
+       int ret = -EINVAL;
+
+       mutex_lock(&thermal_governor_lock);
+       mutex_lock(&tz->lock);
+
+       gov = __find_governor(strim(policy));
+       if (!gov)
+               goto exit;
+
+       ret = thermal_set_governor(tz, gov);
+
+exit:
+       mutex_unlock(&tz->lock);
+       mutex_unlock(&thermal_governor_lock);
+
+       return ret;
+}
+
+int thermal_build_list_of_policies(char *buf)
+{
+       struct thermal_governor *pos;
+       ssize_t count = 0;
+       ssize_t size = PAGE_SIZE;
+
+       mutex_lock(&thermal_governor_lock);
+
+       list_for_each_entry(pos, &thermal_governor_list, governor_list) {
+               size = PAGE_SIZE - count;
+               count += scnprintf(buf + count, size, "%s ", pos->name);
+       }
+       count += scnprintf(buf + count, size, "\n");
+
+       mutex_unlock(&thermal_governor_lock);
+
+       return count;
+}
+
+static int __init thermal_register_governors(void)
+{
+       int result;
+
+       result = thermal_gov_step_wise_register();
+       if (result)
+               return result;
+
+       result = thermal_gov_fair_share_register();
+       if (result)
+               return result;
+
+       result = thermal_gov_bang_bang_register();
+       if (result)
+               return result;
+
+       result = thermal_gov_user_space_register();
+       if (result)
+               return result;
+
+       return thermal_gov_power_allocator_register();
+}
+
+static void thermal_unregister_governors(void)
+{
+       thermal_gov_step_wise_unregister();
+       thermal_gov_fair_share_unregister();
+       thermal_gov_bang_bang_unregister();
+       thermal_gov_user_space_unregister();
+       thermal_gov_power_allocator_unregister();
+}
+
 static int get_idr(struct idr *idr, struct mutex *lock, int *id)
 {
        int ret;
@@ -617,47 +697,6 @@ void thermal_zone_device_unbind_exception(struct thermal_zone_device *tz,
        mutex_unlock(&thermal_list_lock);
 }
 
-int thermal_zone_device_set_policy(struct thermal_zone_device *tz,
-                                  char *policy)
-{
-       struct thermal_governor *gov;
-       int ret = -EINVAL;
-
-       mutex_lock(&thermal_governor_lock);
-       mutex_lock(&tz->lock);
-
-       gov = __find_governor(strim(policy));
-       if (!gov)
-               goto exit;
-
-       ret = thermal_set_governor(tz, gov);
-
-exit:
-       mutex_unlock(&tz->lock);
-       mutex_unlock(&thermal_governor_lock);
-
-       return ret;
-}
-
-int thermal_build_list_of_policies(char *buf)
-{
-       struct thermal_governor *pos;
-       ssize_t count = 0;
-       ssize_t size = PAGE_SIZE;
-
-       mutex_lock(&thermal_governor_lock);
-
-       list_for_each_entry(pos, &thermal_governor_list, governor_list) {
-               size = PAGE_SIZE - count;
-               count += scnprintf(buf + count, size, "%s ", pos->name);
-       }
-       count += scnprintf(buf + count, size, "\n");
-
-       mutex_unlock(&thermal_governor_lock);
-
-       return count;
-}
-
 /* Device management */
 
 /**
@@ -1424,38 +1463,6 @@ static inline int genetlink_init(void) { return 0; }
 static inline void genetlink_exit(void) {}
 #endif /* !CONFIG_NET */
 
-static int __init thermal_register_governors(void)
-{
-       int result;
-
-       result = thermal_gov_step_wise_register();
-       if (result)
-               return result;
-
-       result = thermal_gov_fair_share_register();
-       if (result)
-               return result;
-
-       result = thermal_gov_bang_bang_register();
-       if (result)
-               return result;
-
-       result = thermal_gov_user_space_register();
-       if (result)
-               return result;
-
-       return thermal_gov_power_allocator_register();
-}
-
-static void thermal_unregister_governors(void)
-{
-       thermal_gov_step_wise_unregister();
-       thermal_gov_fair_share_unregister();
-       thermal_gov_bang_bang_unregister();
-       thermal_gov_user_space_unregister();
-       thermal_gov_power_allocator_unregister();
-}
-
 static int thermal_pm_notify(struct notifier_block *nb,
                                unsigned long mode, void *_unused)
 {