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

Commit 3342cd6a 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: I249112ac467b84aea4f08466d91d6be520fbbc14
Signed-off-by: default avatarRam Chandrasekar <rkumbako@codeaurora.org>
parent 3acf3b03
Loading
Loading
Loading
Loading
+2 −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>
@@ -102,7 +101,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);

@@ -635,7 +633,6 @@ __cpufreq_cooling_register(struct device_node *np,
	unsigned int i, num_cpus;
	struct thermal_cooling_device_ops *cooling_ops;
	bool first;
	int ret;

	if (IS_ERR_OR_NULL(policy)) {
		pr_err("%s: cpufreq policy isn't valid: %p\n", __func__, policy);
@@ -681,12 +678,7 @@ __cpufreq_cooling_register(struct device_node *np,
#endif
		cooling_ops = &cpufreq_cooling_ops;

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

	snprintf(dev_name, sizeof(dev_name), "thermal-cpufreq-%d",
		 cpufreq_cdev->id);
@@ -695,7 +687,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_idle_time;

	cpufreq_cdev->clipped_freq = get_state_freq(cpufreq_cdev, 0);
	cpufreq_cdev->floor_freq = get_state_freq(cpufreq_cdev,
@@ -715,8 +707,6 @@ __cpufreq_cooling_register(struct device_node *np,

	return cdev;

remove_ida:
	ida_simple_remove(&cpufreq_ida, cpufreq_cdev->id);
free_idle_time:
	kfree(cpufreq_cdev->idle_time);
free_cdev:
@@ -858,7 +848,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);
}