Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: pressure: bmp280: correct meas_time_us calculation

Correction of meas_time_us initialization based on an observation and
partial patch by David Lechner.

The constant part of the measurement time (as described in the
datasheet and implemented in the BM(P/E)2 Sensor API) was apparently
forgotten (it was already correctly applied for the BMP380) and is now
used.

There was also another thinko in bmp280_wait_conv:
data->oversampling_humid can actually have a value of 0 (for an
oversampling_ratio of 1), so it can not be used to detect the presence
of the humidity measurement capability. Use
data->chip_info->oversampling_humid_avail instead, which is NULL for
chips that cannot measure humidity and therefore must skip that part
of the calculation.

Closes: https://lore.kernel.org/linux-iio/875xgfg0wz.fsf@Gerda.invalid/
Fixes: 26ccfaa9ddaa ("iio: pressure: bmp280: Use sleep and forced mode for oneshot captures")
Suggested-by: David Lechner <dlechner@baylibre.com>
Tested-by: Achim Gratz <Achim.Gratz@Stromeko.DE>
Signed-off-by: Achim Gratz <Achim.Gratz@Stromeko.DE>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Achim Gratz and committed by
Jonathan Cameron
0bf1bfde 8a6b7989

+9 -6
+9 -6
drivers/iio/pressure/bmp280-core.c
··· 1040 1040 unsigned int reg, meas_time_us; 1041 1041 int ret; 1042 1042 1043 - /* Check if we are using a BME280 device */ 1044 - if (data->oversampling_humid) 1045 - meas_time_us = BMP280_PRESS_HUMID_MEAS_OFFSET + 1046 - BIT(data->oversampling_humid) * BMP280_MEAS_DUR; 1043 + /* Constant part of the measurement time */ 1044 + meas_time_us = BMP280_MEAS_OFFSET; 1047 1045 1048 - else 1049 - meas_time_us = 0; 1046 + /* 1047 + * Check if we are using a BME280 device, 1048 + * Humidity measurement time 1049 + */ 1050 + if (data->chip_info->oversampling_humid_avail) 1051 + meas_time_us += BMP280_PRESS_HUMID_MEAS_OFFSET + 1052 + BIT(data->oversampling_humid) * BMP280_MEAS_DUR; 1050 1053 1051 1054 /* Pressure measurement time */ 1052 1055 meas_time_us += BMP280_PRESS_HUMID_MEAS_OFFSET +