diff options
author | Vivien Didelot <vivien.didelot@savoirfairelinux.com> | 2011-03-21 17:59:35 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-03-28 07:31:18 -0700 |
commit | 19333e59fe55be71ee6842f725c25671da91fda7 (patch) | |
tree | 6eb49d480ca1d242c6ca425e1163b607583edb77 | |
parent | fb40a2dbea4eb5f5d422ed8cd85237b9375f4421 (diff) |
hwmon: (sht15) Fix integer overflow in humidity calculation
commit ccd32e735de7a941906e093f8dca924bb05c5794 upstream.
An integer overflow occurs in the calculation of RHlinear when the
relative humidity is greater than around 30%. The consequence is a subtle
(but noticeable) error in the resulting humidity measurement.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/hwmon/sht15.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c index fbc997ee67d..204050720ef 100644 --- a/drivers/hwmon/sht15.c +++ b/drivers/hwmon/sht15.c @@ -332,11 +332,11 @@ static inline int sht15_calc_humid(struct sht15_data *data) const int c1 = -4; const int c2 = 40500; /* x 10 ^ -6 */ - const int c3 = -2800; /* x10 ^ -9 */ + const int c3 = -28; /* x 10 ^ -7 */ RHlinear = c1*1000 + c2 * data->val_humid/1000 - + (data->val_humid * data->val_humid * c3)/1000000; + + (data->val_humid * data->val_humid * c3) / 10000; return (temp - 25000) * (10000 + 80 * data->val_humid) / 1000000 + RHlinear; } |