ARM: tegra: tegratab: Add min/max temperature for Tdiode
Jinyoung Park [Wed, 17 Jul 2013 10:08:25 +0000 (19:08 +0900)]
Added min/max temperature for Tdiode.

Bug 1287901

Signed-off-by: Jinyoung Park <jinyoungp@nvidia.com>
Reviewed-on: http://git-master/r/250222
(cherry picked from commit c70471ba2106aacc8a2d4e59a1e4236684578731)

Change-Id: Ic11fde9b46a4f6d2aa2543dbf792d8910b4d0b45
Signed-off-by: Jinyoung Park <jinyoungp@nvidia.com>
Reviewed-on: http://git-master/r/252888
Reviewed-by: Mrutyunjay Sawant <msawant@nvidia.com>
Tested-by: Mrutyunjay Sawant <msawant@nvidia.com>

arch/arm/mach-tegra/board-tegratab-sensors.c

index 7b6df2a..6901d51 100644 (file)
@@ -763,6 +763,8 @@ static int gadc_thermal_thermistor_adc_to_temp(
 };
 
 #define TDIODE_PRECISION_MULTIPLIER    1000000000LL
+#define TDIODE_MIN_TEMP                        -25000LL
+#define TDIODE_MAX_TEMP                        125000LL
 
 static int gadc_thermal_tdiode_adc_to_temp(
                struct gadc_thermal_platform_data *pdata, int *val, int *val2)
@@ -785,6 +787,8 @@ static int gadc_thermal_tdiode_adc_to_temp(
        temp *= (s64)((*val2) - 2 * (*val));
        temp -= (b2 - 2 * b1);
        temp = div64_s64(temp, (m2 - 2 * m1));
+       temp = min_t(s64, max_t(s64, temp, TDIODE_MIN_TEMP), TDIODE_MAX_TEMP);
+
        return temp;
 };