iio: pressure: bmp280: fix temp compensation
authorIrina Tirdea <irina.tirdea@intel.com>
Wed, 8 Apr 2015 15:26:12 +0000 (18:26 +0300)
committerJonathan Cameron <jic23@kernel.org>
Thu, 9 Apr 2015 11:54:10 +0000 (12:54 +0100)
Temperature reads on bmp280 device always return 0,
due to a missing step in the compensation formula
(data->tfine is never initialized).

Initialize data->tfine value so we get correct
temperature and pressure values.

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Reviewed-by: Vlad Dogaru <vlad.dogaru@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/pressure/bmp280.c

index 7c623e2bd6336c0968254e73547de8945efe4a42..a2602d8dd6d5ceea974cb1fdada67ddde7a2f129 100644 (file)
@@ -172,6 +172,7 @@ static s32 bmp280_compensate_temp(struct bmp280_data *data,
        var2 = (((((adc_temp >> 4) - ((s32)le16_to_cpu(buf[T1]))) *
                  ((adc_temp >> 4) - ((s32)le16_to_cpu(buf[T1])))) >> 12) *
                ((s32)(s16)le16_to_cpu(buf[T3]))) >> 14;
+       data->t_fine = var1 + var2;
 
        return (data->t_fine * 5 + 128) >> 8;
 }