Commit 4235f684 authored by Jonathan Cameron's avatar Jonathan Cameron Committed by Jean Delvare

hwmon: (sht15) Off-by-one error in array index + incorrect constants

Fix an off-by-one error in array index + incorrect constants.
Signed-off-by: default avatarChristoph Walser <walser@tik.ee.ethz.ch>
Signed-off-by: default avatarJonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
parent 70c38772
...@@ -305,7 +305,7 @@ static inline int sht15_calc_temp(struct sht15_data *data) ...@@ -305,7 +305,7 @@ static inline int sht15_calc_temp(struct sht15_data *data)
int d1 = 0; int d1 = 0;
int i; int i;
for (i = 1; i < ARRAY_SIZE(temppoints) - 1; i++) for (i = 1; i < ARRAY_SIZE(temppoints); i++)
/* Find pointer to interpolate */ /* Find pointer to interpolate */
if (data->supply_uV > temppoints[i - 1].vdd) { if (data->supply_uV > temppoints[i - 1].vdd) {
d1 = (data->supply_uV/1000 - temppoints[i - 1].vdd) d1 = (data->supply_uV/1000 - temppoints[i - 1].vdd)
...@@ -332,12 +332,12 @@ static inline int sht15_calc_humid(struct sht15_data *data) ...@@ -332,12 +332,12 @@ static inline int sht15_calc_humid(struct sht15_data *data)
const int c1 = -4; const int c1 = -4;
const int c2 = 40500; /* x 10 ^ -6 */ const int c2 = 40500; /* x 10 ^ -6 */
const int c3 = 2800; /* x10 ^ -9 */ const int c3 = -2800; /* x10 ^ -9 */
RHlinear = c1*1000 RHlinear = c1*1000
+ c2 * data->val_humid/1000 + c2 * data->val_humid/1000
+ (data->val_humid * data->val_humid * c3)/1000000; + (data->val_humid * data->val_humid * c3)/1000000;
return (temp - 25000) * (10000 + 800 * data->val_humid) return (temp - 25000) * (10000 + 80 * data->val_humid)
/ 1000000 + RHlinear; / 1000000 + RHlinear;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment