aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorJerome Oufella <jerome.oufella@savoirfairelinux.com>2010-04-14 10:14:07 -0400
committerJean Delvare <khali@linux-fr.org>2010-04-14 10:14:07 -0400
commit328a2c22abd08911e37fa66f1358f829cecd72e9 (patch)
tree31f33c7b72b522eed0ab4d5da9904cc726471937 /drivers/hwmon
parent2ba3abd8186f24c7fb418927025b4e2120e3a362 (diff)
hwmon: (sht15) Fix sht15_calc_temp interpolation function
I discovered two issues. First the previous sht15_calc_temp() loop did not iterate through the temppoints array since the (data->supply_uV > temppoints[i - 1].vdd) test is always true in this direction. Also the two-points linear interpolation function was returning biased values due to a stray division by 1000 which shouldn't be there. [JD: Also change the default value for d1 from 0 to something saner.] Signed-off-by: Jerome Oufella <jerome.oufella@savoirfairelinux.com> Acked-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Jean Delvare <khali@linux-fr.org> Cc: stable@kernel.org
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/sht15.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
index 6b2d8ae64fe1..9a15b1af1f11 100644
--- a/drivers/hwmon/sht15.c
+++ b/drivers/hwmon/sht15.c
@@ -303,13 +303,13 @@ error_ret:
303 **/ 303 **/
304static inline int sht15_calc_temp(struct sht15_data *data) 304static inline int sht15_calc_temp(struct sht15_data *data)
305{ 305{
306 int d1 = 0; 306 int d1 = temppoints[0].d1;
307 int i; 307 int i;
308 308
309 for (i = 1; i < ARRAY_SIZE(temppoints); i++) 309 for (i = ARRAY_SIZE(temppoints) - 1; i > 0; i--)
310 /* Find pointer to interpolate */ 310 /* Find pointer to interpolate */
311 if (data->supply_uV > temppoints[i - 1].vdd) { 311 if (data->supply_uV > temppoints[i - 1].vdd) {
312 d1 = (data->supply_uV/1000 - temppoints[i - 1].vdd) 312 d1 = (data->supply_uV - temppoints[i - 1].vdd)
313 * (temppoints[i].d1 - temppoints[i - 1].d1) 313 * (temppoints[i].d1 - temppoints[i - 1].d1)
314 / (temppoints[i].vdd - temppoints[i - 1].vdd) 314 / (temppoints[i].vdd - temppoints[i - 1].vdd)
315 + temppoints[i - 1].d1; 315 + temppoints[i - 1].d1;