All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] thermal: of-thermal: return -EAGAIN until thermal_zone_of_sensor_register() was called
@ 2016-01-20  5:53 Kuninori Morimoto
  0 siblings, 0 replies; only message in thread
From: Kuninori Morimoto @ 2016-01-20  5:53 UTC (permalink / raw)
  To: Eduardo Valentin; +Cc: Zhang Rui, Simon, Magnus, Linux-Kernel

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

of_parse_thermal_zones() will call thermal_zone_device_register(), and it
calls thermal_zone_get_temp() before calling thermal_zone_of_sensor_register()
which setup .get_temp on thermal_zone_of_add_sensor.
Because of this setting path, thermal_zone_device_register() will call
.get_temp and it gets -EINVAL from thermal_zone_get_temp().
Thus, kernel always indicates

        thermal thermal_zone0: failed to read out thermal zone (-22)

This patch solves this issue.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 drivers/thermal/of-thermal.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index 440ea63..729e2d4 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -89,6 +89,15 @@ struct __thermal_zone {
 };
 
 /***   DT thermal zone device callbacks   ***/
+static int of_thermal_null_get_temp(struct thermal_zone_device *tz,
+				       int *temp)
+{
+	/*
+	 * This function will be replaced with
+	 * of_thermal_get_temp() by thermal_zone_of_add_sensor()
+	 */
+	return -EAGAIN;
+}
 
 static int of_thermal_get_temp(struct thermal_zone_device *tz,
 			       int *temp)
@@ -383,6 +392,7 @@ static struct thermal_zone_device_ops of_thermal_ops = {
 	.get_mode = of_thermal_get_mode,
 	.set_mode = of_thermal_set_mode,
 
+	.get_temp      = of_thermal_null_get_temp,
 	.get_trip_type = of_thermal_get_trip_type,
 	.get_trip_temp = of_thermal_get_trip_temp,
 	.set_trip_temp = of_thermal_set_trip_temp,
@@ -549,7 +559,7 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
 		return;
 
 	mutex_lock(&tzd->lock);
-	tzd->ops->get_temp = NULL;
+	tzd->ops->get_temp = of_thermal_null_get_temp;
 	tzd->ops->get_trend = NULL;
 	tzd->ops->set_emul_temp = NULL;
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-01-20  5:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-20  5:53 [PATCH] thermal: of-thermal: return -EAGAIN until thermal_zone_of_sensor_register() was called Kuninori Morimoto

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.