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>
This commit is contained in:
parent
ffbcdf8a75
commit
5440c40b90
1 changed files with 11 additions and 1 deletions
|
@ -203,6 +203,7 @@ static int rcar_thermal_update_temp(struct rcar_thermal_priv *priv)
|
||||||
static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp)
|
static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp)
|
||||||
{
|
{
|
||||||
struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
|
struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
|
||||||
|
int tmp;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = rcar_thermal_update_temp(priv);
|
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;
|
return ret;
|
||||||
|
|
||||||
mutex_lock(&priv->lock);
|
mutex_lock(&priv->lock);
|
||||||
*temp = MCELSIUS((priv->ctemp * 5) - 65);
|
tmp = MCELSIUS((priv->ctemp * 5) - 65);
|
||||||
mutex_unlock(&priv->lock);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue