diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2015-12-14 20:18:13 -0500 |
---|---|---|
committer | Eduardo Valentin <edubezval@gmail.com> | 2016-01-06 21:06:39 -0500 |
commit | 5440c40b900fa561add48a7e70e9c892f0551387 (patch) | |
tree | 08bb806d88c4806b66a41c181a6093e25eb7ef94 | |
parent | ffbcdf8a759c6dde71c6c4f646a552f7637bcca7 (diff) |
thermal: rcar: rcar_thermal_get_temp() return error if strange temp
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
-rw-r--r-- | drivers/thermal/rcar_thermal.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c index fb81fd7e6b81..44b9c485157d 100644 --- a/drivers/thermal/rcar_thermal.c +++ b/drivers/thermal/rcar_thermal.c | |||
@@ -203,6 +203,7 @@ err_out_unlock: | |||
203 | static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp) | 203 | static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp) |
204 | { | 204 | { |
205 | struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone); | 205 | struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone); |
206 | int tmp; | ||
206 | int ret; | 207 | int ret; |
207 | 208 | ||
208 | ret = rcar_thermal_update_temp(priv); | 209 | ret = rcar_thermal_update_temp(priv); |
@@ -210,9 +211,18 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp) | |||
210 | return ret; | 211 | return ret; |
211 | 212 | ||
212 | mutex_lock(&priv->lock); | 213 | mutex_lock(&priv->lock); |
213 | *temp = MCELSIUS((priv->ctemp * 5) - 65); | 214 | tmp = MCELSIUS((priv->ctemp * 5) - 65); |
214 | mutex_unlock(&priv->lock); | 215 | mutex_unlock(&priv->lock); |
215 | 216 | ||
217 | if ((tmp < MCELSIUS(-45)) || (tmp > MCELSIUS(125))) { | ||
218 | struct device *dev = rcar_priv_to_dev(priv); | ||
219 | |||
220 | dev_err(dev, "it couldn't measure temperature correctly\n"); | ||
221 | return -EIO; | ||
222 | } | ||
223 | |||
224 | *temp = tmp; | ||
225 | |||
216 | return 0; | 226 | return 0; |
217 | } | 227 | } |
218 | 228 | ||