Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux...
[muen/linux.git] / drivers / thermal / imx_thermal.c
index b1f82d64253e1077b86a2d20954330f436ef09bc..aa452acb60b6c93f2ca0d8ace93aa7c4cc883d32 100644 (file)
@@ -3,6 +3,7 @@
 // Copyright 2013 Freescale Semiconductor, Inc.
 
 #include <linux/clk.h>
+#include <linux/cpu.h>
 #include <linux/cpufreq.h>
 #include <linux/cpu_cooling.h>
 #include <linux/delay.h>
@@ -647,6 +648,27 @@ static const struct of_device_id of_imx_thermal_match[] = {
 };
 MODULE_DEVICE_TABLE(of, of_imx_thermal_match);
 
+/*
+ * Create cooling device in case no #cooling-cells property is available in
+ * CPU node
+ */
+static int imx_thermal_register_legacy_cooling(struct imx_thermal_data *data)
+{
+       struct device_node *np = of_get_cpu_node(data->policy->cpu, NULL);
+       int ret;
+
+       if (!np || !of_find_property(np, "#cooling-cells", NULL)) {
+               data->cdev = cpufreq_cooling_register(data->policy);
+               if (IS_ERR(data->cdev)) {
+                       ret = PTR_ERR(data->cdev);
+                       cpufreq_cpu_put(data->policy);
+                       return ret;
+               }
+       }
+
+       return 0;
+}
+
 static int imx_thermal_probe(struct platform_device *pdev)
 {
        struct imx_thermal_data *data;
@@ -727,12 +749,10 @@ static int imx_thermal_probe(struct platform_device *pdev)
                return -EPROBE_DEFER;
        }
 
-       data->cdev = cpufreq_cooling_register(data->policy);
-       if (IS_ERR(data->cdev)) {
-               ret = PTR_ERR(data->cdev);
+       ret = imx_thermal_register_legacy_cooling(data);
+       if (ret) {
                dev_err(&pdev->dev,
                        "failed to register cpufreq cooling device: %d\n", ret);
-               cpufreq_cpu_put(data->policy);
                return ret;
        }