aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2014-12-03 23:12:00 -0500
committerEduardo Valentin <edubezval@gmail.com>2014-12-08 13:04:56 -0500
commit5194fe469927e50367b35e556812c7fc6ce130d1 (patch)
tree51673e1f5f719c631e466cb3ffff0ab981927f75
parent7adb635b3cd790e4e0d7e9d0b3dd30574ae36596 (diff)
thermal: cpu_cooling: Merge cpufreq_apply_cooling() into cpufreq_set_cur_state()
cpufreq_apply_cooling() has a single caller, cpufreq_set_cur_state() and cpufreq_set_cur_state() is an unnecessary wrapper over cpufreq_apply_cooling(). Get rid of it by merging both routines. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
-rw-r--r--drivers/thermal/cpu_cooling.c52
1 files changed, 16 insertions, 36 deletions
diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index 86bcf8dc14d3..a3dd74f57540 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -254,41 +254,6 @@ static unsigned int get_cpu_frequency(unsigned int cpu, unsigned long level)
254} 254}
255 255
256/** 256/**
257 * cpufreq_apply_cooling - function to apply frequency clipping.
258 * @cpufreq_device: cpufreq_cooling_device pointer containing frequency
259 * clipping data.
260 * @cooling_state: value of the cooling state.
261 *
262 * Function used to make sure the cpufreq layer is aware of current thermal
263 * limits. The limits are applied by updating the cpufreq policy.
264 *
265 * Return: 0 on success, an error code otherwise (-EINVAL in case wrong
266 * cooling state).
267 */
268static int cpufreq_apply_cooling(struct cpufreq_cooling_device *cpufreq_device,
269 unsigned long cooling_state)
270{
271 unsigned int clip_freq;
272 struct cpumask *mask = &cpufreq_device->allowed_cpus;
273 unsigned int cpu = cpumask_any(mask);
274
275 /* Check if the old cooling action is same as new cooling action */
276 if (cpufreq_device->cpufreq_state == cooling_state)
277 return 0;
278
279 clip_freq = get_cpu_frequency(cpu, cooling_state);
280 if (!clip_freq)
281 return -EINVAL;
282
283 cpufreq_device->cpufreq_state = cooling_state;
284 cpufreq_device->cpufreq_val = clip_freq;
285
286 cpufreq_update_policy(cpu);
287
288 return 0;
289}
290
291/**
292 * cpufreq_thermal_notifier - notifier callback for cpufreq policy change. 257 * cpufreq_thermal_notifier - notifier callback for cpufreq policy change.
293 * @nb: struct notifier_block * with callback info. 258 * @nb: struct notifier_block * with callback info.
294 * @event: value showing cpufreq event for which this function invoked. 259 * @event: value showing cpufreq event for which this function invoked.
@@ -391,8 +356,23 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev,
391 unsigned long state) 356 unsigned long state)
392{ 357{
393 struct cpufreq_cooling_device *cpufreq_device = cdev->devdata; 358 struct cpufreq_cooling_device *cpufreq_device = cdev->devdata;
359 unsigned int cpu = cpumask_any(&cpufreq_device->allowed_cpus);
360 unsigned int clip_freq;
361
362 /* Check if the old cooling action is same as new cooling action */
363 if (cpufreq_device->cpufreq_state == state)
364 return 0;
394 365
395 return cpufreq_apply_cooling(cpufreq_device, state); 366 clip_freq = get_cpu_frequency(cpu, state);
367 if (!clip_freq)
368 return -EINVAL;
369
370 cpufreq_device->cpufreq_state = state;
371 cpufreq_device->cpufreq_val = clip_freq;
372
373 cpufreq_update_policy(cpu);
374
375 return 0;
396} 376}
397 377
398/* Bind cpufreq callbacks to thermal cooling device ops */ 378/* Bind cpufreq callbacks to thermal cooling device ops */