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

Commit 4d753aa7 authored by Viresh Kumar's avatar Viresh Kumar Committed by Eduardo Valentin
Browse files

thermal: cpu_cooling: use cpufreq_policy to register cooling device



The CPU cooling driver uses the cpufreq policy, to get clip_cpus, the
frequency table, etc. Most of the callers of CPU cooling driver's
registration routines have the cpufreq policy with them, but they only
pass the policy->related_cpus cpumask. The __cpufreq_cooling_register()
routine then gets the policy by itself and uses it.

It would be much better if the callers can pass the policy instead
directly. This also fixes a basic design flaw, where the policy can be
freed while the CPU cooling driver is still active.

Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: default avatarLukasz Luba <lukasz.luba@arm.com>
Tested-by: default avatarLukasz Luba <lukasz.luba@arm.com>
Signed-off-by: default avatarEduardo Valentin <edubezval@gmail.com>
parent 18f301c9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -540,7 +540,7 @@ static void bL_cpufreq_ready(struct cpufreq_policy *policy)
				     &power_coefficient);

		cdev[cur_cluster] = of_cpufreq_power_cooling_register(np,
				policy->related_cpus, power_coefficient, NULL);
				policy, power_coefficient, NULL);
		if (IS_ERR(cdev[cur_cluster])) {
			dev_err(cpu_dev,
				"running cpufreq without cooling device: %ld\n",
+1 −1
Original line number Diff line number Diff line
@@ -326,7 +326,7 @@ static void cpufreq_ready(struct cpufreq_policy *policy)
				     &power_coefficient);

		priv->cdev = of_cpufreq_power_cooling_register(np,
				policy->related_cpus, power_coefficient, NULL);
				policy, power_coefficient, NULL);
		if (IS_ERR(priv->cdev)) {
			dev_err(priv->cpu_dev,
				"running cpufreq without cooling device: %ld\n",
+1 −1
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ static int dbx500_cpufreq_exit(struct cpufreq_policy *policy)

static void dbx500_cpufreq_ready(struct cpufreq_policy *policy)
{
	cdev = cpufreq_cooling_register(policy->cpus);
	cdev = cpufreq_cooling_register(policy);
	if (IS_ERR(cdev))
		pr_err("Failed to register cooling device %ld\n", PTR_ERR(cdev));
	else
+1 −3
Original line number Diff line number Diff line
@@ -320,9 +320,7 @@ static void mtk_cpufreq_ready(struct cpufreq_policy *policy)
		of_property_read_u32(np, DYNAMIC_POWER, &capacitance);

		info->cdev = of_cpufreq_power_cooling_register(np,
						policy->related_cpus,
						capacitance,
						NULL);
						policy, capacitance, NULL);

		if (IS_ERR(info->cdev)) {
			dev_err(info->cpu_dev,
+1 −2
Original line number Diff line number Diff line
@@ -278,8 +278,7 @@ static void qoriq_cpufreq_ready(struct cpufreq_policy *policy)
	struct device_node *np = of_get_cpu_node(policy->cpu, NULL);

	if (of_find_property(np, "#cooling-cells", NULL)) {
		cpud->cdev = of_cpufreq_cooling_register(np,
							 policy->related_cpus);
		cpud->cdev = of_cpufreq_cooling_register(np, policy);

		if (IS_ERR(cpud->cdev) && PTR_ERR(cpud->cdev) != -ENOSYS) {
			pr_err("cpu%d is not running as cooling device: %ld\n",
Loading