diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2015-12-15 02:18:13 +0100 |
---|---|---|
committer | Eduardo Valentin <edubezval@gmail.com> | 2016-01-07 03:06:39 +0100 |
commit | 5440c40b900fa561add48a7e70e9c892f0551387 (patch) | |
tree | 08bb806d88c4806b66a41c181a6093e25eb7ef94 /drivers | |
parent | thermal: rcar: check irq possibility in rcar_thermal_irq_xxx() (diff) | |
download | linux-5440c40b900fa561add48a7e70e9c892f0551387.tar.xz linux-5440c40b900fa561add48a7e70e9c892f0551387.zip |
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>
Diffstat (limited to 'drivers')
-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: static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp) { struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone); + int tmp; int ret; ret = rcar_thermal_update_temp(priv); @@ -210,9 +211,18 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp) return ret; mutex_lock(&priv->lock); - *temp = MCELSIUS((priv->ctemp * 5) - 65); + tmp = MCELSIUS((priv->ctemp * 5) - 65); mutex_unlock(&priv->lock); + if ((tmp < MCELSIUS(-45)) || (tmp > MCELSIUS(125))) { + struct device *dev = rcar_priv_to_dev(priv); + + dev_err(dev, "it couldn't measure temperature correctly\n"); + return -EIO; + } + + *temp = tmp; + return 0; } |