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

Commit f1553334 authored by Eduardo Valentin's avatar Eduardo Valentin Committed by Greg Kroah-Hartman
Browse files

staging: ti-soc-thermal: defer probe if cpufreq is not ready



When builtin compiled, there is a chance for this driver
be probed before cpufreq driver is up and running. In this
case, the cpucooling device can be wrong initialized.

Thus, this patch makes sure this driver is probed only
when cpufreq driver is ready. Whenever there is no
cpufreq driver registered, the probe will return -EPROBE_DEFER.

Tested-by: default avatarJ Keerthy <j-keerthy@ti.com>
Signed-off-by: default avatarEduardo Valentin <eduardo.valentin@ti.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 537eb936
Loading
Loading
Loading
Loading
+22 −5
Original line number Original line Diff line number Diff line
@@ -1305,12 +1305,18 @@ int ti_bandgap_probe(struct platform_device *pdev)
	for (i = 0; i < bgp->conf->sensor_count; i++) {
	for (i = 0; i < bgp->conf->sensor_count; i++) {
		char *domain;
		char *domain;


		if (bgp->conf->sensors[i].register_cooling)
		if (bgp->conf->sensors[i].register_cooling) {
			bgp->conf->sensors[i].register_cooling(bgp, i);
			ret = bgp->conf->sensors[i].register_cooling(bgp, i);
			if (ret)
				goto remove_sensors;
		}


		if (bgp->conf->expose_sensor) {
			domain = bgp->conf->sensors[i].domain;
			domain = bgp->conf->sensors[i].domain;
		if (bgp->conf->expose_sensor)
			ret = bgp->conf->expose_sensor(bgp, i, domain);
			bgp->conf->expose_sensor(bgp, i, domain);
			if (ret)
				goto remove_last_cooling;
		}
	}
	}


	/*
	/*
@@ -1329,6 +1335,17 @@ int ti_bandgap_probe(struct platform_device *pdev)


	return 0;
	return 0;


remove_last_cooling:
	if (bgp->conf->sensors[i].unregister_cooling)
		bgp->conf->sensors[i].unregister_cooling(bgp, i);
remove_sensors:
	for (i--; i >= 0; i--) {
		if (bgp->conf->sensors[i].unregister_cooling)
			bgp->conf->sensors[i].unregister_cooling(bgp, i);
		if (bgp->conf->remove_sensor)
			bgp->conf->remove_sensor(bgp, i);
	}
	ti_bandgap_power(bgp, false);
disable_clk:
disable_clk:
	if (TI_BANDGAP_HAS(bgp, CLK_CTRL))
	if (TI_BANDGAP_HAS(bgp, CLK_CTRL))
		clk_disable_unprepare(bgp->fclock);
		clk_disable_unprepare(bgp->fclock);
+5 −0
Original line number Original line Diff line number Diff line
@@ -339,6 +339,11 @@ int ti_thermal_register_cpu_cooling(struct ti_bandgap *bgp, int id)
	if (!data)
	if (!data)
		return -EINVAL;
		return -EINVAL;


	if (!cpufreq_get_current_driver()) {
		dev_dbg(bgp->dev, "no cpufreq driver yet\n");
		return -EPROBE_DEFER;
	}

	/* Register cooling device */
	/* Register cooling device */
	data->cool_dev = cpufreq_cooling_register(cpu_present_mask);
	data->cool_dev = cpufreq_cooling_register(cpu_present_mask);
	if (IS_ERR_OR_NULL(data->cool_dev)) {
	if (IS_ERR_OR_NULL(data->cool_dev)) {