aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/thermal/cpu_cooling.c
diff options
context:
space:
mode:
authorEduardo Valentin <eduardo.valentin@ti.com>2013-09-12 19:26:45 -0400
committerEduardo Valentin <eduardo.valentin@ti.com>2013-12-04 08:33:34 -0500
commit39d99cff76bf2992fd6dd4b1fc62da139e62e90c (patch)
tree632c6d587d4bac910705dd43fa4f854a1f9bb901 /drivers/thermal/cpu_cooling.c
parenta116b5d44f144586ef03a93f14ddc63f4a85e906 (diff)
thermal: cpu_cooling: introduce of_cpufreq_cooling_register
This patch introduces an API to register cpufreq cooling device based on device tree node. The registration via device tree node differs from normal registration due to the fact that it is needed to fill the device_node structure in order to be able to match the cooling devices with trip points. Cc: Zhang Rui <rui.zhang@intel.com> Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
Diffstat (limited to 'drivers/thermal/cpu_cooling.c')
-rw-r--r--drivers/thermal/cpu_cooling.c56
1 files changed, 50 insertions, 6 deletions
diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index 02a46f23d14c..a6cb5531403f 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -417,18 +417,21 @@ static struct notifier_block thermal_cpufreq_notifier_block = {
417}; 417};
418 418
419/** 419/**
420 * cpufreq_cooling_register - function to create cpufreq cooling device. 420 * __cpufreq_cooling_register - helper function to create cpufreq cooling device
421 * @np: a valid struct device_node to the cooling device device tree node
421 * @clip_cpus: cpumask of cpus where the frequency constraints will happen. 422 * @clip_cpus: cpumask of cpus where the frequency constraints will happen.
422 * 423 *
423 * This interface function registers the cpufreq cooling device with the name 424 * This interface function registers the cpufreq cooling device with the name
424 * "thermal-cpufreq-%x". This api can support multiple instances of cpufreq 425 * "thermal-cpufreq-%x". This api can support multiple instances of cpufreq
425 * cooling devices. 426 * cooling devices. It also gives the opportunity to link the cooling device
427 * with a device tree node, in order to bind it via the thermal DT code.
426 * 428 *
427 * Return: a valid struct thermal_cooling_device pointer on success, 429 * Return: a valid struct thermal_cooling_device pointer on success,
428 * on failure, it returns a corresponding ERR_PTR(). 430 * on failure, it returns a corresponding ERR_PTR().
429 */ 431 */
430struct thermal_cooling_device * 432static struct thermal_cooling_device *
431cpufreq_cooling_register(const struct cpumask *clip_cpus) 433__cpufreq_cooling_register(struct device_node *np,
434 const struct cpumask *clip_cpus)
432{ 435{
433 struct thermal_cooling_device *cool_dev; 436 struct thermal_cooling_device *cool_dev;
434 struct cpufreq_cooling_device *cpufreq_dev = NULL; 437 struct cpufreq_cooling_device *cpufreq_dev = NULL;
@@ -467,8 +470,8 @@ cpufreq_cooling_register(const struct cpumask *clip_cpus)
467 snprintf(dev_name, sizeof(dev_name), "thermal-cpufreq-%d", 470 snprintf(dev_name, sizeof(dev_name), "thermal-cpufreq-%d",
468 cpufreq_dev->id); 471 cpufreq_dev->id);
469 472
470 cool_dev = thermal_cooling_device_register(dev_name, cpufreq_dev, 473 cool_dev = thermal_of_cooling_device_register(np, dev_name, cpufreq_dev,
471 &cpufreq_cooling_ops); 474 &cpufreq_cooling_ops);
472 if (IS_ERR(cool_dev)) { 475 if (IS_ERR(cool_dev)) {
473 release_idr(&cpufreq_idr, cpufreq_dev->id); 476 release_idr(&cpufreq_idr, cpufreq_dev->id);
474 kfree(cpufreq_dev); 477 kfree(cpufreq_dev);
@@ -488,9 +491,50 @@ cpufreq_cooling_register(const struct cpumask *clip_cpus)
488 491
489 return cool_dev; 492 return cool_dev;
490} 493}
494
495/**
496 * cpufreq_cooling_register - function to create cpufreq cooling device.
497 * @clip_cpus: cpumask of cpus where the frequency constraints will happen.
498 *
499 * This interface function registers the cpufreq cooling device with the name
500 * "thermal-cpufreq-%x". This api can support multiple instances of cpufreq
501 * cooling devices.
502 *
503 * Return: a valid struct thermal_cooling_device pointer on success,
504 * on failure, it returns a corresponding ERR_PTR().
505 */
506struct thermal_cooling_device *
507cpufreq_cooling_register(const struct cpumask *clip_cpus)
508{
509 return __cpufreq_cooling_register(NULL, clip_cpus);
510}
491EXPORT_SYMBOL_GPL(cpufreq_cooling_register); 511EXPORT_SYMBOL_GPL(cpufreq_cooling_register);
492 512
493/** 513/**
514 * of_cpufreq_cooling_register - function to create cpufreq cooling device.
515 * @np: a valid struct device_node to the cooling device device tree node
516 * @clip_cpus: cpumask of cpus where the frequency constraints will happen.
517 *
518 * This interface function registers the cpufreq cooling device with the name
519 * "thermal-cpufreq-%x". This api can support multiple instances of cpufreq
520 * cooling devices. Using this API, the cpufreq cooling device will be
521 * linked to the device tree node provided.
522 *
523 * Return: a valid struct thermal_cooling_device pointer on success,
524 * on failure, it returns a corresponding ERR_PTR().
525 */
526struct thermal_cooling_device *
527of_cpufreq_cooling_register(struct device_node *np,
528 const struct cpumask *clip_cpus)
529{
530 if (!np)
531 return ERR_PTR(-EINVAL);
532
533 return __cpufreq_cooling_register(np, clip_cpus);
534}
535EXPORT_SYMBOL_GPL(of_cpufreq_cooling_register);
536
537/**
494 * cpufreq_cooling_unregister - function to remove cpufreq cooling device. 538 * cpufreq_cooling_unregister - function to remove cpufreq cooling device.
495 * @cdev: thermal cooling device pointer. 539 * @cdev: thermal cooling device pointer.
496 * 540 *