Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 95f45caa authored by Ram Chandrasekar's avatar Ram Chandrasekar
Browse files

drivers: thermal: cpu_cooling: Use CPU ID as cooling device ID



CPU cooling device will use IDR to get integer numbers for defining
the CPU cooling device ID. With having one cooling device per policy,
it will be tough to correlate a cooling device ID to the policy it is
mitigating.

Use the CPU ID from the policy as cooling device ID, which will allow
easy mapping of cooling device to CPU.

Change-Id: I81cdae2f1cf1a19839c1bb8a189a01d67cff74a8
Signed-off-by: default avatarRam Chandrasekar <rkumbako@codeaurora.org>
parent b2b2111a
Loading
Loading
Loading
Loading
+3 −13
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@
#include <linux/thermal.h>
#include <linux/cpufreq.h>
#include <linux/err.h>
#include <linux/idr.h>
#include <linux/pm_opp.h>
#include <linux/slab.h>
#include <linux/cpu.h>
@@ -113,7 +112,6 @@ struct cpufreq_cooling_device {
	struct cpu_cooling_ops *plat_ops;
};

static DEFINE_IDA(cpufreq_ida);
static DEFINE_MUTEX(cooling_list_lock);
static LIST_HEAD(cpufreq_cdev_list);

@@ -760,12 +758,7 @@ __cpufreq_cooling_register(struct device_node *np,
		goto free_idle_time;
	}

	ret = ida_simple_get(&cpufreq_ida, 0, 0, GFP_KERNEL);
	if (ret < 0) {
		cdev = ERR_PTR(ret);
		goto free_table;
	}
	cpufreq_cdev->id = ret;
	cpufreq_cdev->id = policy->cpu;

	snprintf(dev_name, sizeof(dev_name), "thermal-cpufreq-%d",
		 cpufreq_cdev->id);
@@ -786,7 +779,7 @@ __cpufreq_cooling_register(struct device_node *np,
		ret = update_freq_table(cpufreq_cdev, capacitance);
		if (ret) {
			cdev = ERR_PTR(ret);
			goto remove_ida;
			goto free_table;
		}

		cooling_ops = &cpufreq_power_cooling_ops;
@@ -799,7 +792,7 @@ __cpufreq_cooling_register(struct device_node *np,
	cdev = thermal_of_cooling_device_register(np, dev_name, cpufreq_cdev,
						  cooling_ops);
	if (IS_ERR(cdev))
		goto remove_ida;
		goto free_table;

	cpufreq_cdev->clipped_freq = cpufreq_cdev->freq_table[0].frequency;
	cpufreq_cdev->floor_freq =
@@ -819,8 +812,6 @@ __cpufreq_cooling_register(struct device_node *np,

	return cdev;

remove_ida:
	ida_simple_remove(&cpufreq_ida, cpufreq_cdev->id);
free_table:
	kfree(cpufreq_cdev->freq_table);
free_idle_time:
@@ -969,7 +960,6 @@ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev)
	}

	thermal_cooling_device_unregister(cpufreq_cdev->cdev);
	ida_simple_remove(&cpufreq_ida, cpufreq_cdev->id);
	kfree(cpufreq_cdev->idle_time);
	kfree(cpufreq_cdev->freq_table);
	kfree(cpufreq_cdev);