diff options
| author | Zhang Rui <rui.zhang@intel.com> | 2013-04-26 21:28:56 -0400 |
|---|---|---|
| committer | Zhang Rui <rui.zhang@intel.com> | 2013-04-26 21:28:56 -0400 |
| commit | 8f578bfefdd13d28d5baf3345405c46b101fe2f5 (patch) | |
| tree | bc5288ac0f07ba92943b48b8d490c7c5825a3fcd | |
| parent | 09681dfa554743041a3dbd9ca87a320c908c37f4 (diff) | |
| parent | d44ada516277f5d58b9bda2ea0a2c9503b316bbf (diff) | |
Merge branch 'cpu_cooling-doc-comments-update' of .git into next
| -rw-r--r-- | drivers/thermal/cpu_cooling.c | 50 | ||||
| -rw-r--r-- | include/linux/cpu_cooling.h | 16 |
2 files changed, 37 insertions, 29 deletions
diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index a294921be650..c94bf2e5de62 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c | |||
| @@ -64,6 +64,11 @@ static struct cpufreq_cooling_device *notify_device; | |||
| 64 | * get_idr - function to get a unique id. | 64 | * get_idr - function to get a unique id. |
| 65 | * @idr: struct idr * handle used to create a id. | 65 | * @idr: struct idr * handle used to create a id. |
| 66 | * @id: int * value generated by this function. | 66 | * @id: int * value generated by this function. |
| 67 | * | ||
| 68 | * This function will populate @id with an unique | ||
| 69 | * id, using the idr API. | ||
| 70 | * | ||
| 71 | * Return: 0 on success, an error code on failure. | ||
| 67 | */ | 72 | */ |
| 68 | static int get_idr(struct idr *idr, int *id) | 73 | static int get_idr(struct idr *idr, int *id) |
| 69 | { | 74 | { |
| @@ -75,6 +80,7 @@ static int get_idr(struct idr *idr, int *id) | |||
| 75 | if (unlikely(ret < 0)) | 80 | if (unlikely(ret < 0)) |
| 76 | return ret; | 81 | return ret; |
| 77 | *id = ret; | 82 | *id = ret; |
| 83 | |||
| 78 | return 0; | 84 | return 0; |
| 79 | } | 85 | } |
| 80 | 86 | ||
| @@ -105,6 +111,7 @@ static void release_idr(struct idr *idr, int id) | |||
| 105 | static int is_cpufreq_valid(int cpu) | 111 | static int is_cpufreq_valid(int cpu) |
| 106 | { | 112 | { |
| 107 | struct cpufreq_policy policy; | 113 | struct cpufreq_policy policy; |
| 114 | |||
| 108 | return !cpufreq_get_policy(&policy, cpu); | 115 | return !cpufreq_get_policy(&policy, cpu); |
| 109 | } | 116 | } |
| 110 | 117 | ||
| @@ -134,7 +141,8 @@ enum cpufreq_cooling_property { | |||
| 134 | * Return: 0 on success, -EINVAL when invalid parameters are passed. | 141 | * Return: 0 on success, -EINVAL when invalid parameters are passed. |
| 135 | */ | 142 | */ |
| 136 | static int get_property(unsigned int cpu, unsigned long input, | 143 | static int get_property(unsigned int cpu, unsigned long input, |
| 137 | unsigned int* output, enum cpufreq_cooling_property property) | 144 | unsigned int *output, |
| 145 | enum cpufreq_cooling_property property) | ||
| 138 | { | 146 | { |
| 139 | int i, j; | 147 | int i, j; |
| 140 | unsigned long max_level = 0, level = 0; | 148 | unsigned long max_level = 0, level = 0; |
| @@ -142,14 +150,13 @@ static int get_property(unsigned int cpu, unsigned long input, | |||
| 142 | int descend = -1; | 150 | int descend = -1; |
| 143 | struct cpufreq_frequency_table *table = | 151 | struct cpufreq_frequency_table *table = |
| 144 | cpufreq_frequency_get_table(cpu); | 152 | cpufreq_frequency_get_table(cpu); |
| 145 | 153 | ||
| 146 | if (!output) | 154 | if (!output) |
| 147 | return -EINVAL; | 155 | return -EINVAL; |
| 148 | 156 | ||
| 149 | if (!table) | 157 | if (!table) |
| 150 | return -EINVAL; | 158 | return -EINVAL; |
| 151 | 159 | ||
| 152 | |||
| 153 | for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { | 160 | for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { |
| 154 | /* ignore invalid entries */ | 161 | /* ignore invalid entries */ |
| 155 | if (table[i].frequency == CPUFREQ_ENTRY_INVALID) | 162 | if (table[i].frequency == CPUFREQ_ENTRY_INVALID) |
| @@ -174,8 +181,7 @@ static int get_property(unsigned int cpu, unsigned long input, | |||
| 174 | } | 181 | } |
| 175 | 182 | ||
| 176 | if (property == GET_FREQ) | 183 | if (property == GET_FREQ) |
| 177 | level = descend ? input : (max_level - input -1); | 184 | level = descend ? input : (max_level - input - 1); |
| 178 | |||
| 179 | 185 | ||
| 180 | for (i = 0, j = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { | 186 | for (i = 0, j = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { |
| 181 | /* ignore invalid entry */ | 187 | /* ignore invalid entry */ |
| @@ -201,6 +207,7 @@ static int get_property(unsigned int cpu, unsigned long input, | |||
| 201 | } | 207 | } |
| 202 | j++; | 208 | j++; |
| 203 | } | 209 | } |
| 210 | |||
| 204 | return -EINVAL; | 211 | return -EINVAL; |
| 205 | } | 212 | } |
| 206 | 213 | ||
| @@ -221,6 +228,7 @@ unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq) | |||
| 221 | 228 | ||
| 222 | if (get_property(cpu, (unsigned long)freq, &val, GET_LEVEL)) | 229 | if (get_property(cpu, (unsigned long)freq, &val, GET_LEVEL)) |
| 223 | return THERMAL_CSTATE_INVALID; | 230 | return THERMAL_CSTATE_INVALID; |
| 231 | |||
| 224 | return (unsigned long)val; | 232 | return (unsigned long)val; |
| 225 | } | 233 | } |
| 226 | EXPORT_SYMBOL_GPL(cpufreq_cooling_get_level); | 234 | EXPORT_SYMBOL_GPL(cpufreq_cooling_get_level); |
| @@ -245,6 +253,7 @@ static unsigned int get_cpu_frequency(unsigned int cpu, unsigned long level) | |||
| 245 | ret = get_property(cpu, level, &freq, GET_FREQ); | 253 | ret = get_property(cpu, level, &freq, GET_FREQ); |
| 246 | if (ret) | 254 | if (ret) |
| 247 | return 0; | 255 | return 0; |
| 256 | |||
| 248 | return freq; | 257 | return freq; |
| 249 | } | 258 | } |
| 250 | 259 | ||
| @@ -261,7 +270,7 @@ static unsigned int get_cpu_frequency(unsigned int cpu, unsigned long level) | |||
| 261 | * cooling state). | 270 | * cooling state). |
| 262 | */ | 271 | */ |
| 263 | static int cpufreq_apply_cooling(struct cpufreq_cooling_device *cpufreq_device, | 272 | static int cpufreq_apply_cooling(struct cpufreq_cooling_device *cpufreq_device, |
| 264 | unsigned long cooling_state) | 273 | unsigned long cooling_state) |
| 265 | { | 274 | { |
| 266 | unsigned int cpuid, clip_freq; | 275 | unsigned int cpuid, clip_freq; |
| 267 | struct cpumask *mask = &cpufreq_device->allowed_cpus; | 276 | struct cpumask *mask = &cpufreq_device->allowed_cpus; |
| @@ -303,7 +312,7 @@ static int cpufreq_apply_cooling(struct cpufreq_cooling_device *cpufreq_device, | |||
| 303 | * Return: 0 (success) | 312 | * Return: 0 (success) |
| 304 | */ | 313 | */ |
| 305 | static int cpufreq_thermal_notifier(struct notifier_block *nb, | 314 | static int cpufreq_thermal_notifier(struct notifier_block *nb, |
| 306 | unsigned long event, void *data) | 315 | unsigned long event, void *data) |
| 307 | { | 316 | { |
| 308 | struct cpufreq_policy *policy = data; | 317 | struct cpufreq_policy *policy = data; |
| 309 | unsigned long max_freq = 0; | 318 | unsigned long max_freq = 0; |
| @@ -314,7 +323,7 @@ static int cpufreq_thermal_notifier(struct notifier_block *nb, | |||
| 314 | if (cpumask_test_cpu(policy->cpu, ¬ify_device->allowed_cpus)) | 323 | if (cpumask_test_cpu(policy->cpu, ¬ify_device->allowed_cpus)) |
| 315 | max_freq = notify_device->cpufreq_val; | 324 | max_freq = notify_device->cpufreq_val; |
| 316 | 325 | ||
| 317 | /* Never exceed user_policy.max*/ | 326 | /* Never exceed user_policy.max */ |
| 318 | if (max_freq > policy->user_policy.max) | 327 | if (max_freq > policy->user_policy.max) |
| 319 | max_freq = policy->user_policy.max; | 328 | max_freq = policy->user_policy.max; |
| 320 | 329 | ||
| @@ -324,9 +333,7 @@ static int cpufreq_thermal_notifier(struct notifier_block *nb, | |||
| 324 | return 0; | 333 | return 0; |
| 325 | } | 334 | } |
| 326 | 335 | ||
| 327 | /* | 336 | /* cpufreq cooling device callback functions are defined below */ |
| 328 | * cpufreq cooling device callback functions are defined below | ||
| 329 | */ | ||
| 330 | 337 | ||
| 331 | /** | 338 | /** |
| 332 | * cpufreq_get_max_state - callback function to get the max cooling state. | 339 | * cpufreq_get_max_state - callback function to get the max cooling state. |
| @@ -373,6 +380,7 @@ static int cpufreq_get_cur_state(struct thermal_cooling_device *cdev, | |||
| 373 | struct cpufreq_cooling_device *cpufreq_device = cdev->devdata; | 380 | struct cpufreq_cooling_device *cpufreq_device = cdev->devdata; |
| 374 | 381 | ||
| 375 | *state = cpufreq_device->cpufreq_state; | 382 | *state = cpufreq_device->cpufreq_state; |
| 383 | |||
| 376 | return 0; | 384 | return 0; |
| 377 | } | 385 | } |
| 378 | 386 | ||
| @@ -417,8 +425,8 @@ static struct notifier_block thermal_cpufreq_notifier_block = { | |||
| 417 | * Return: a valid struct thermal_cooling_device pointer on success, | 425 | * Return: a valid struct thermal_cooling_device pointer on success, |
| 418 | * on failure, it returns a corresponding ERR_PTR(). | 426 | * on failure, it returns a corresponding ERR_PTR(). |
| 419 | */ | 427 | */ |
| 420 | struct thermal_cooling_device *cpufreq_cooling_register( | 428 | struct thermal_cooling_device * |
| 421 | const struct cpumask *clip_cpus) | 429 | cpufreq_cooling_register(const struct cpumask *clip_cpus) |
| 422 | { | 430 | { |
| 423 | struct thermal_cooling_device *cool_dev; | 431 | struct thermal_cooling_device *cool_dev; |
| 424 | struct cpufreq_cooling_device *cpufreq_dev = NULL; | 432 | struct cpufreq_cooling_device *cpufreq_dev = NULL; |
| @@ -427,9 +435,9 @@ struct thermal_cooling_device *cpufreq_cooling_register( | |||
| 427 | int ret = 0, i; | 435 | int ret = 0, i; |
| 428 | struct cpufreq_policy policy; | 436 | struct cpufreq_policy policy; |
| 429 | 437 | ||
| 430 | /*Verify that all the clip cpus have same freq_min, freq_max limit*/ | ||
