Skip to content

Commit

Permalink
thermal: rcar: rcar_thermal_get_temp() return error if strange temp
Browse files Browse the repository at this point in the history
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
  • Loading branch information
Kuninori Morimoto authored and Eduardo Valentin committed Jan 7, 2016
1 parent ffbcdf8 commit 5440c40
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion drivers/thermal/rcar_thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,26 @@ static int rcar_thermal_update_temp(struct rcar_thermal_priv *priv)
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);
if (ret < 0)
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;
}

Expand Down

0 comments on commit 5440c40

Please sign in to comment.