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

Commit 61c04572 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull thermal fixes from Zhang Rui:

 - Fix cpu_cooling to have separate thermal_cooling_device_ops
   structures for cpus with and without power model, to avoid NULL
   dereference in cpufreq_state2power.  From Brendan Jackman.

 - Fix a possible NULL dereference in imx_thermal driver.  From Corentin
   LABBE.

 - Another two trivial fixes, one typo fix and one deleting module
   owner.  From Caesar Wang and Markus Elfring.

* 'for-rc' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux:
  thermal: imx: fix a possible NULL dereference
  thermal: trivial: fix the typo
  Thermal-INT3406: Delete owner assignment
  thermal: cpu_cooling: Fix NULL dereference in cpufreq_state2power
parents 4935e04e 829bc78a
Loading
Loading
Loading
Loading
+16 −5
Original line number Original line Diff line number Diff line
@@ -740,12 +740,22 @@ static int cpufreq_power2state(struct thermal_cooling_device *cdev,
}
}


/* Bind cpufreq callbacks to thermal cooling device ops */
/* Bind cpufreq callbacks to thermal cooling device ops */

static struct thermal_cooling_device_ops cpufreq_cooling_ops = {
static struct thermal_cooling_device_ops cpufreq_cooling_ops = {
	.get_max_state = cpufreq_get_max_state,
	.get_max_state = cpufreq_get_max_state,
	.get_cur_state = cpufreq_get_cur_state,
	.get_cur_state = cpufreq_get_cur_state,
	.set_cur_state = cpufreq_set_cur_state,
	.set_cur_state = cpufreq_set_cur_state,
};
};


static struct thermal_cooling_device_ops cpufreq_power_cooling_ops = {
	.get_max_state		= cpufreq_get_max_state,
	.get_cur_state		= cpufreq_get_cur_state,
	.set_cur_state		= cpufreq_set_cur_state,
	.get_requested_power	= cpufreq_get_requested_power,
	.state2power		= cpufreq_state2power,
	.power2state		= cpufreq_power2state,
};

/* Notifier for cpufreq policy change */
/* Notifier for cpufreq policy change */
static struct notifier_block thermal_cpufreq_notifier_block = {
static struct notifier_block thermal_cpufreq_notifier_block = {
	.notifier_call = cpufreq_thermal_notifier,
	.notifier_call = cpufreq_thermal_notifier,
@@ -795,6 +805,7 @@ __cpufreq_cooling_register(struct device_node *np,
	struct cpumask temp_mask;
	struct cpumask temp_mask;
	unsigned int freq, i, num_cpus;
	unsigned int freq, i, num_cpus;
	int ret;
	int ret;
	struct thermal_cooling_device_ops *cooling_ops;


	cpumask_and(&temp_mask, clip_cpus, cpu_online_mask);
	cpumask_and(&temp_mask, clip_cpus, cpu_online_mask);
	policy = cpufreq_cpu_get(cpumask_first(&temp_mask));
	policy = cpufreq_cpu_get(cpumask_first(&temp_mask));
@@ -850,10 +861,6 @@ __cpufreq_cooling_register(struct device_node *np,
	cpumask_copy(&cpufreq_dev->allowed_cpus, clip_cpus);
	cpumask_copy(&cpufreq_dev->allowed_cpus, clip_cpus);


	if (capacitance) {
	if (capacitance) {
		cpufreq_cooling_ops.get_requested_power =
			cpufreq_get_requested_power;
		cpufreq_cooling_ops.state2power = cpufreq_state2power;
		cpufreq_cooling_ops.power2state = cpufreq_power2state;
		cpufreq_dev->plat_get_static_power = plat_static_func;
		cpufreq_dev->plat_get_static_power = plat_static_func;


		ret = build_dyn_power_table(cpufreq_dev, capacitance);
		ret = build_dyn_power_table(cpufreq_dev, capacitance);
@@ -861,6 +868,10 @@ __cpufreq_cooling_register(struct device_node *np,
			cool_dev = ERR_PTR(ret);
			cool_dev = ERR_PTR(ret);
			goto free_table;
			goto free_table;
		}
		}

		cooling_ops = &cpufreq_power_cooling_ops;
	} else {
		cooling_ops = &cpufreq_cooling_ops;
	}
	}


	ret = get_idr(&cpufreq_idr, &cpufreq_dev->id);
	ret = get_idr(&cpufreq_idr, &cpufreq_dev->id);
@@ -885,7 +896,7 @@ __cpufreq_cooling_register(struct device_node *np,
		 cpufreq_dev->id);
		 cpufreq_dev->id);


	cool_dev = thermal_of_cooling_device_register(np, dev_name, cpufreq_dev,
	cool_dev = thermal_of_cooling_device_register(np, dev_name, cpufreq_dev,
						      &cpufreq_cooling_ops);
						      cooling_ops);
	if (IS_ERR(cool_dev))
	if (IS_ERR(cool_dev))
		goto remove_idr;
		goto remove_idr;


+1 −3
Original line number Original line Diff line number Diff line
@@ -471,8 +471,6 @@ MODULE_DEVICE_TABLE(of, of_imx_thermal_match);


static int imx_thermal_probe(struct platform_device *pdev)
static int imx_thermal_probe(struct platform_device *pdev)
{
{
	const struct of_device_id *of_id =
		of_match_device(of_imx_thermal_match, &pdev->dev);
	struct imx_thermal_data *data;
	struct imx_thermal_data *data;
	struct regmap *map;
	struct regmap *map;
	int measure_freq;
	int measure_freq;
@@ -490,7 +488,7 @@ static int imx_thermal_probe(struct platform_device *pdev)
	}
	}
	data->tempmon = map;
	data->tempmon = map;


	data->socdata = of_id->data;
	data->socdata = of_device_get_match_data(&pdev->dev);


	/* make sure the IRQ flag is clear before enabling irq on i.MX6SX */
	/* make sure the IRQ flag is clear before enabling irq on i.MX6SX */
	if (data->socdata->version == TEMPMON_IMX6SX) {
	if (data->socdata->version == TEMPMON_IMX6SX) {
+0 −1
Original line number Original line Diff line number Diff line
@@ -225,7 +225,6 @@ static struct platform_driver int3406_thermal_driver = {
	.remove = int3406_thermal_remove,
	.remove = int3406_thermal_remove,
	.driver = {
	.driver = {
		   .name = "int3406 thermal",
		   .name = "int3406 thermal",
		   .owner = THIS_MODULE,
		   .acpi_match_table = int3406_thermal_match,
		   .acpi_match_table = int3406_thermal_match,
		   },
		   },
};
};
+5 −5

File changed.

Contains only whitespace changes.