return level - 1;
}
+/**
+ * cpufreq_cooling_get_level - for a given cpu, return the cooling level.
+ * @cpu: cpu for which the level is required
+ * @freq: the frequency of interest
+ *
+ * This function will match the cooling level corresponding to the
+ * requested @freq and return it.
+ *
+ * Return: The matched cooling level on success or THERMAL_CSTATE_INVALID
+ * otherwise.
+ */
+unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq)
+{
+ struct cpufreq_cooling_device *cpufreq_cdev;
+
+ mutex_lock(&cooling_list_lock);
+ list_for_each_entry(cpufreq_cdev, &cpufreq_cdev_list, node) {
+ if (cpumask_test_cpu(cpu, cpufreq_cdev->policy->related_cpus)) {
+ unsigned long level = get_level(cpufreq_cdev, freq);
+
+ mutex_unlock(&cooling_list_lock);
+ return level;
+ }
+ }
+ mutex_unlock(&cooling_list_lock);
+
+ pr_err("%s: cpu:%d not part of any cooling device\n", __func__, cpu);
+ return THERMAL_CSTATE_INVALID;
+}
+EXPORT_SYMBOL_GPL(cpufreq_cooling_get_level);
+
/**
* cpufreq_thermal_notifier - notifier callback for cpufreq policy change.
* @nb: struct notifier_block * with callback info.