]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/thermal/cpu_cooling.c
thermal: cpu_cooling: propagate error returned by idr_alloc()
[karo-tx-linux.git] / drivers / thermal / cpu_cooling.c
index cc10641be111dce7f03dccbf49720d069fb9fadc..5c9a2efeec2214051e9218df0e38a976b1f81954 100644 (file)
 #include <linux/cpu.h>
 #include <linux/cpu_cooling.h>
 
+/*
+ * Cooling state <-> CPUFreq frequency
+ *
+ * Cooling states are translated to frequencies throughout this driver and this
+ * is the relation between them.
+ *
+ * Highest cooling state corresponds to lowest possible frequency.
+ *
+ * i.e.
+ *     level 0 --> 1st Max Freq
+ *     level 1 --> 2nd Max Freq
+ *     ...
+ */
+
 /**
  * struct cpufreq_cooling_device - data for cooling device with cpufreq
  * @id: unique integer value corresponding to each cpufreq_cooling_device
@@ -437,10 +451,10 @@ __cpufreq_cooling_register(struct device_node *np,
                           const struct cpumask *clip_cpus)
 {
        struct thermal_cooling_device *cool_dev;
-       struct cpufreq_cooling_device *cpufreq_dev = NULL;
+       struct cpufreq_cooling_device *cpufreq_dev;
        unsigned int min = 0, max = 0;
        char dev_name[THERMAL_NAME_LENGTH];
-       int ret = 0, i;
+       int ret, i;
        struct cpufreq_policy policy;
 
        if (!cpufreq_frequency_get_table(cpumask_first(clip_cpus))) {
@@ -462,8 +476,7 @@ __cpufreq_cooling_register(struct device_node *np,
                                return ERR_PTR(-EINVAL);
                }
        }
-       cpufreq_dev = kzalloc(sizeof(struct cpufreq_cooling_device),
-                             GFP_KERNEL);
+       cpufreq_dev = kzalloc(sizeof(*cpufreq_dev), GFP_KERNEL);
        if (!cpufreq_dev)
                return ERR_PTR(-ENOMEM);
 
@@ -472,7 +485,7 @@ __cpufreq_cooling_register(struct device_node *np,
        ret = get_idr(&cpufreq_idr, &cpufreq_dev->id);
        if (ret) {
                kfree(cpufreq_dev);
-               return ERR_PTR(-EINVAL);
+               return ERR_PTR(ret);
        }
 
        snprintf(dev_name, sizeof(dev_name), "thermal-cpufreq-%d",
@@ -486,7 +499,7 @@ __cpufreq_cooling_register(struct device_node *np,
                return cool_dev;
        }
        cpufreq_dev->cool_dev = cool_dev;
-       cpufreq_dev->cpufreq_state = 0;
+
        mutex_lock(&cooling_cpufreq_lock);
 
        /* Register the notifier for first cpufreq cooling device */