提交 abad3983 编写于 作者: I Irina Tirdea 提交者: Jonathan Cameron

iio: pressure: bmp280: fix temp compensation

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: NIrina Tirdea <irina.tirdea@intel.com>
Reviewed-by: NVlad Dogaru <vlad.dogaru@intel.com>
Signed-off-by: NJonathan Cameron <jic23@kernel.org>
上级 c610f7f7
...@@ -172,6 +172,7 @@ static s32 bmp280_compensate_temp(struct bmp280_data *data, ...@@ -172,6 +172,7 @@ static s32 bmp280_compensate_temp(struct bmp280_data *data,
var2 = (((((adc_temp >> 4) - ((s32)le16_to_cpu(buf[T1]))) * var2 = (((((adc_temp >> 4) - ((s32)le16_to_cpu(buf[T1]))) *
((adc_temp >> 4) - ((s32)le16_to_cpu(buf[T1])))) >> 12) * ((adc_temp >> 4) - ((s32)le16_to_cpu(buf[T1])))) >> 12) *
((s32)(s16)le16_to_cpu(buf[T3]))) >> 14; ((s32)(s16)le16_to_cpu(buf[T3]))) >> 14;
data->t_fine = var1 + var2;
return (data->t_fine * 5 + 128) >> 8; return (data->t_fine * 5 + 128) >> 8;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册