Skip to contentSkip to conversation

iio: pressure: bmp280: fix temp compensation

PATCH Applied Irina Tirdea 3 participants 3 messages Apr 8, 2015 – Apr 9, 2015 IIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 drivers/iio/pressure/bmp280.c | 1 +
 1 file changed, 1 insertion(+)
drivers/iio/pressure/bmp280.c +1 -0
index 7c623e2..a2602d8 100644
@@ -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;
 }
Signature · 1 line
1.9.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Irina Tirdea

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.

Nice catch, this must have been lost during a refactoring.

Thanks,
Vlad

maintainer Applied
#2 lore raw
Quoted 8 lines · Vlad Dogaru
Quoted 7 lines · Irina Tirdea

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.

Quoted 9 lines
Quoted 1 line

Nice catch, this must have been lost during a refactoring.

Thanks,
Vlad

Thanks,

Applied to fixes-togreg which is now based on staging-next which gives you an idea of when this will go to Greg now!