aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhang Rui <rui.zhang@intel.com>2013-03-26 04:38:29 -0400
committerZhang Rui <rui.zhang@intel.com>2013-04-14 11:28:43 -0400
commit80a26a5c22b90a82b8696cb72c1d09d525ada53e (patch)
tree4ab06fb87e9e3e6364ad234b0594f6ac40227cdc
parent5fc024ab474de7d5798b7ad85f3df260dbab1353 (diff)
Thermal: build thermal governors into thermal_sys module
The thermal governors are part of the thermal framework, rather than a seperate feature/module. Because the generic thermal layer can not work without thermal governors, and it must load the thermal governors during its initialization. Build them into one module in this patch. This also fix a problem that the generic thermal layer does not work when CONFIG_THERMAL=m and CONFIG_THERMAL_GOV_XXX=y. Signed-off-by: Zhang Rui <rui.zhang@intel.com> Acked-by: Eduardo Valentin <eduardo.valentin@ti.com> Acked-by: Durgadoss R <durgadoss.r@intel.com>
-rw-r--r--Documentation/thermal/sysfs-api.txt8
-rw-r--r--drivers/thermal/Makefile6
-rw-r--r--drivers/thermal/fair_share.c15
-rw-r--r--drivers/thermal/step_wise.c16
-rw-r--r--drivers/thermal/thermal_core.c59
-rw-r--r--drivers/thermal/thermal_core.h27
-rw-r--r--drivers/thermal/user_space.c15
-rw-r--r--include/linux/thermal.h4
8 files changed, 84 insertions, 66 deletions
diff --git a/Documentation/thermal/sysfs-api.txt b/Documentation/thermal/sysfs-api.txt
index 277530a5786c..b2ffe98cf469 100644
--- a/Documentation/thermal/sysfs-api.txt
+++ b/Documentation/thermal/sysfs-api.txt
@@ -379,11 +379,3 @@ platform data is provided, this uses the step_wise throttling policy.
379This function serves as an arbitrator to set the state of a cooling 379This function serves as an arbitrator to set the state of a cooling
380device. It sets the cooling device to the deepest cooling state if 380device. It sets the cooling device to the deepest cooling state if
381possible. 381possible.
382
3835.5:thermal_register_governor:
384This function lets the various thermal governors to register themselves
385with the Thermal framework. At run time, depending on a zone's platform
386data, a particular governor is used for throttling.
387
3885.6:thermal_unregister_governor:
389This function unregisters a governor from the thermal framework.
diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
index 1bf2eab50b27..b17bfb055498 100644
--- a/drivers/thermal/Makefile
+++ b/drivers/thermal/Makefile
@@ -6,9 +6,9 @@ obj-$(CONFIG_THERMAL) += thermal_sys.o
6thermal_sys-y += thermal_core.o 6thermal_sys-y += thermal_core.o
7 7
8# governors 8# governors
9obj-$(CONFIG_THERMAL_GOV_FAIR_SHARE) += fair_share.o 9thermal_sys-$(CONFIG_THERMAL_GOV_FAIR_SHARE) += fair_share.o
10obj-$(CONFIG_THERMAL_GOV_STEP_WISE) += step_wise.o 10thermal_sys-$(CONFIG_THERMAL_GOV_STEP_WISE) += step_wise.o
11obj-$(CONFIG_THERMAL_GOV_USER_SPACE) += user_space.o 11thermal_sys-$(CONFIG_THERMAL_GOV_USER_SPACE) += user_space.o
12 12
13# cpufreq cooling 13# cpufreq cooling
14obj-$(CONFIG_CPU_THERMAL) += cpu_cooling.o 14obj-$(CONFIG_CPU_THERMAL) += cpu_cooling.o
diff --git a/drivers/thermal/fair_share.c b/drivers/thermal/fair_share.c
index 792479f2b64b..944ba2f340c8 100644
--- a/drivers/thermal/fair_share.c
+++ b/drivers/thermal/fair_share.c
@@ -22,9 +22,6 @@
22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23 */ 23 */
24 24
25#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
26
27#include <linux/module.h>
28#include <linux/thermal.h> 25#include <linux/thermal.h>
29 26
30#include "thermal_core.h" 27#include "thermal_core.h"
@@ -111,23 +108,15 @@ static int fair_share_throttle(struct thermal_zone_device *tz, int trip)
111static struct thermal_governor thermal_gov_fair_share = { 108static struct thermal_governor thermal_gov_fair_share = {
112 .name = "fair_share", 109 .name = "fair_share",
113 .throttle = fair_share_throttle, 110 .throttle = fair_share_throttle,
114 .owner = THIS_MODULE,
115}; 111};
116 112
117static int __init thermal_gov_fair_share_init(void) 113int thermal_gov_fair_share_register(void)
118{ 114{
119 return thermal_register_governor(&thermal_gov_fair_share); 115 return thermal_register_governor(&thermal_gov_fair_share);
120} 116}
121 117
122static void __exit thermal_gov_fair_share_exit(void) 118void thermal_gov_fair_share_unregister(void)
123{ 119{
124 thermal_unregister_governor(&thermal_gov_fair_share); 120 thermal_unregister_governor(&thermal_gov_fair_share);
125} 121}
126 122
127/* This should load after thermal framework */
128fs_initcall(thermal_gov_fair_share_init);
129module_exit(thermal_gov_fair_share_exit);
130
131MODULE_AUTHOR("Durgadoss R");
132MODULE_DESCRIPTION("A simple weight based thermal throttling governor");
133MODULE_LICENSE("GPL");
diff --git a/drivers/thermal/step_wise.c b/drivers/thermal/step_wise.c
index ca4f79fb72cf..4d4ddae1a991 100644
--- a/drivers/thermal/step_wise.c
+++ b/drivers/thermal/step_wise.c
@@ -22,9 +22,6 @@
22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23 */ 23 */
24 24
25#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
26
27#include <linux/module.h>
28#include <linux/thermal.h> 25#include <linux/thermal.h>
29 26
30#include "thermal_core.h" 27#include "thermal_core.h"
@@ -186,23 +183,14 @@ static int step_wise_throttle(struct thermal_zone_device *tz, int trip)
186static struct thermal_governor thermal_gov_step_wise = { 183static struct thermal_governor thermal_gov_step_wise = {
187 .name = "step_wise", 184 .name = "step_wise",
188 .throttle = step_wise_throttle, 185 .throttle = step_wise_throttle,
189 .owner = THIS_MODULE,
190}; 186};
191 187
192static int __init thermal_gov_step_wise_init(void) 188int thermal_gov_step_wise_register(void)
193{ 189{
194 return thermal_register_governor(&thermal_gov_step_wise); 190 return thermal_register_governor(&thermal_gov_step_wise);
195} 191}
196 192
197static void __exit thermal_gov_step_wise_exit(void) 193void thermal_gov_step_wise_unregister(void)
198{ 194{
199 thermal_unregister_governor(&thermal_gov_step_wise); 195 thermal_unregister_governor(&thermal_gov_step_wise);
200} 196}
201
202/* This should load after thermal framework */
203fs_initcall(thermal_gov_step_wise_init);
204module_exit(thermal_gov_step_wise_exit);
205
206MODULE_AUTHOR("Durgadoss R");
207MODULE_DESCRIPTION("A step-by-step thermal throttling governor");
208MODULE_LICENSE("GPL");
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 5b7863a03f98..4cdc3e327222 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -99,7 +99,6 @@ int thermal_register_governor(struct thermal_governor *governor)
99 99
100 return err; 100 return err;
101} 101}
102EXPORT_SYMBOL_GPL(thermal_register_governor);
103 102
104void thermal_unregister_governor(struct thermal_governor *governor) 103void thermal_unregister_governor(struct thermal_governor *governor)
105{ 104{
@@ -127,7 +126,6 @@ exit:
127 mutex_unlock(&thermal_governor_lock); 126 mutex_unlock(&thermal_governor_lock);
128 return; 127 return;
129} 128}
130EXPORT_SYMBOL_GPL(thermal_unregister_governor);
131 129
132static int get_idr(struct idr *idr, struct mutex *lock, int *id) 130static int get_idr(struct idr *idr, struct mutex *lock, int *id)
133{ 131{
@@ -1858,30 +1856,69 @@ static inline int genetlink_init(void) { return 0; }
1858static inline void genetlink_exit(void) {} 1856static inline void genetlink_exit(void) {}
1859#endif /* !CONFIG_NET */ 1857#endif /* !CONFIG_NET */
1860 1858
1859static int __init thermal_register_governors(void)
1860{
1861 int result;
1862
1863 result = thermal_gov_step_wise_register();
1864 if (result)
1865 return result;
1866
1867 result = thermal_gov_fair_share_register();
1868 if (result)
1869 return result;
1870
1871 return thermal_gov_user_space_register();
1872}
1873
1874static void thermal_unregister_governors(void)
1875{
1876 thermal_gov_step_wise_unregister();
1877 thermal_gov_fair_share_unregister();
1878 thermal_gov_user_space_unregister();
1879}
1880
1861static int __init thermal_init(void) 1881static int __init thermal_init(void)
1862{ 1882{
1863 int result = 0; 1883 int result;
1884
1885 result = thermal_register_governors();
1886 if (result)
1887 goto error;
1864 1888
1865 result = class_register(&thermal_class); 1889 result = class_register(&thermal_class);
1866 if (result) { 1890 if (result)
1867 idr_destroy(&thermal_tz_idr); 1891 goto unregister_governors;
1868 idr_destroy(&thermal_cdev_idr); 1892
1869 mutex_destroy(&thermal_idr_lock);
1870 mutex_destroy(&thermal_list_lock);
1871 return result;
1872 }
1873 result = genetlink_init(); 1893 result = genetlink_init();
1894 if (result)
1895 goto unregister_class;
1896
1897 return 0;
1898
1899unregister_governors:
1900 thermal_unregister_governors();
1901unregister_class:
1902 class_unregister(&thermal_class);
1903error:
1904 idr_destroy(&thermal_tz_idr);
1905 idr_destroy(&thermal_cdev_idr);
1906 mutex_destroy(&thermal_idr_lock);
1907 mutex_destroy(&thermal_list_lock);
1908 mutex_destroy(&thermal_governor_lock);
1874 return result; 1909 return result;
1875} 1910}
1876 1911
1877static void __exit thermal_exit(void) 1912static void __exit thermal_exit(void)
1878{ 1913{
1914 genetlink_exit();
1879 class_unregister(&thermal_class); 1915 class_unregister(&thermal_class);
1916 thermal_unregister_governors();
1880 idr_destroy(&thermal_tz_idr); 1917 idr_destroy(&thermal_tz_idr);
1881 idr_destroy(&thermal_cdev_idr); 1918 idr_destroy(&thermal_cdev_idr);
1882 mutex_destroy(&thermal_idr_lock); 1919 mutex_destroy(&thermal_idr_lock);
1883 mutex_destroy(&thermal_list_lock); 1920 mutex_destroy(&thermal_list_lock);
1884 genetlink_exit(); 1921 mutex_destroy(&thermal_governor_lock);
1885} 1922}
1886 1923
1887fs_initcall(thermal_init); 1924fs_initcall(thermal_init);
diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
index 0d3205a18112..7cf2f6626251 100644
--- a/drivers/thermal/thermal_core.h
+++ b/drivers/thermal/thermal_core.h
@@ -50,4 +50,31 @@ struct thermal_instance {
50 struct list_head cdev_node; /* node in cdev->thermal_instances */ 50 struct list_head cdev_node; /* node in cdev->thermal_instances */
51}; 51};
52 52
53int thermal_register_governor(struct thermal_governor *);
54void thermal_unregister_governor(struct thermal_governor *);
55
56#ifdef CONFIG_THERMAL_GOV_STEP_WISE
57int thermal_gov_step_wise_register(void);
58void thermal_gov_step_wise_unregister(void);
59#else
60static inline int thermal_gov_step_wise_register(void) { return 0; }
61static inline void thermal_gov_step_wise_unregister(void) {}
62#endif /* CONFIG_THERMAL_GOV_STEP_WISE */
63
64#ifdef CONFIG_THERMAL_GOV_FAIR_SHARE
65int thermal_gov_fair_share_register(void);
66void thermal_gov_fair_share_unregister(void);
67#else
68static inline int thermal_gov_fair_share_register(void) { return 0; }
69static inline void thermal_gov_fair_share_unregister(void) {}
70#endif /* CONFIG_THERMAL_GOV_FAIR_SHARE */
71
72#ifdef CONFIG_THERMAL_GOV_USER_SPACE
73int thermal_gov_user_space_register(void);
74void thermal_gov_user_space_unregister(void);
75#else
76static inline int thermal_gov_user_space_register(void) { return 0; }
77static inline void thermal_gov_user_space_unregister(void) {}
78#endif /* CONFIG_THERMAL_GOV_USER_SPACE */
79
53#endif /* __THERMAL_CORE_H__ */ 80#endif /* __THERMAL_CORE_H__ */
diff --git a/drivers/thermal/user_space.c b/drivers/thermal/user_space.c
index 6bbb380b6d19..10adcddc8821 100644
--- a/drivers/thermal/user_space.c
+++ b/drivers/thermal/user_space.c
@@ -22,9 +22,6 @@
22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23 */ 23 */
24 24
25#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
26
27#include <linux/module.h>
28#include <linux/thermal.h> 25#include <linux/thermal.h>
29 26
30#include "thermal_core.h" 27#include "thermal_core.h"
@@ -46,23 +43,15 @@ static int notify_user_space(struct thermal_zone_device *tz, int trip)
46static struct thermal_governor thermal_gov_user_space = { 43static struct thermal_governor thermal_gov_user_space = {
47 .name = "user_space", 44 .name = "user_space",
48 .throttle = notify_user_space, 45 .throttle = notify_user_space,
49 .owner = THIS_MODULE,
50}; 46};
51 47
52static int __init thermal_gov_user_space_init(void) 48int thermal_gov_user_space_register(void)
53{ 49{
54 return thermal_register_governor(&thermal_gov_user_space); 50 return thermal_register_governor(&thermal_gov_user_space);
55} 51}
56 52
57static void __exit thermal_gov_user_space_exit(void) 53void thermal_gov_user_space_unregister(void)
58{ 54{
59 thermal_unregister_governor(&thermal_gov_user_space); 55 thermal_unregister_governor(&thermal_gov_user_space);
60} 56}
61 57
62/* This should load after thermal framework */
63fs_initcall(thermal_gov_user_space_init);
64module_exit(thermal_gov_user_space_exit);
65
66MODULE_AUTHOR("Durgadoss R");
67MODULE_DESCRIPTION("A user space Thermal notifier");
68MODULE_LICENSE("GPL");
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 5a3b428daaab..4445b951b57e 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -187,7 +187,6 @@ struct thermal_governor {
187 char name[THERMAL_NAME_LENGTH]; 187 char name[THERMAL_NAME_LENGTH];
188 int (*throttle)(struct thermal_zone_device *tz, int trip); 188 int (*throttle)(struct thermal_zone_device *tz, int trip);
189 struct list_head governor_list; 189 struct list_head governor_list;
190 struct module *owner;
191}; 190};
192 191
193/* Structure that holds binding parameters for a zone */ 192/* Structure that holds binding parameters for a zone */
@@ -247,9 +246,6 @@ struct thermal_instance *get_thermal_instance(struct thermal_zone_device *,
247void thermal_cdev_update(struct thermal_cooling_device *); 246void thermal_cdev_update(struct thermal_cooling_device *);
248void notify_thermal_framework(struct thermal_zone_device *, int); 247void notify_thermal_framework(struct thermal_zone_device *, int);
249 248
250int thermal_register_governor(struct thermal_governor *);
251void thermal_unregister_governor(struct thermal_governor *);
252
253#ifdef CONFIG_NET 249#ifdef CONFIG_NET
254extern int thermal_generate_netlink_event(struct thermal_zone_device *tz, 250extern int thermal_generate_netlink_event(struct thermal_zone_device *tz,
255 enum events event); 251 enum events event);