]> git.karo-electronics.de Git - linux-beck.git/commitdiff
thermal: rcar: rcar_thermal_get_temp() return error if strange temp
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tue, 15 Dec 2015 01:18:13 +0000 (01:18 +0000)
committerEduardo Valentin <edubezval@gmail.com>
Thu, 7 Jan 2016 02:06:39 +0000 (18:06 -0800)
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
drivers/thermal/rcar_thermal.c

index fb81fd7e6b81a8646d0399c88e70bfe96a0b324b..44b9c485157d8c6e624548ee7c7cfccacea241d9 100644 (file)
@@ -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;
 }