Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1312897

[PATCH] thermal: of-thermal: return -EAGAIN until thermal_zone_of_sensor_register() was called

From Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Newsgroups linux.kernel
Subject [PATCH] thermal: of-thermal: return -EAGAIN until thermal_zone_of_sensor_register() was called
Date 2016-01-20 07:00 +0100
Message-ID <qSTYe-28T-3@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH] thermal: of-thermal: return -EAGAIN until thermal_zone_of_sensor_register() was called Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> - 2016-01-20 07:00 +0100

csiph-web