]> www.infradead.org Git - users/jedix/linux-maple.git/commit
iio: pressure: bmp280: Refactorize reading functions
authorVasileios Amoiridis <vassilisamir@gmail.com>
Sun, 12 May 2024 23:05:20 +0000 (01:05 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 27 May 2024 08:48:57 +0000 (09:48 +0100)
commit5d6e6c6ec45d1bf077d42ccb759bbdb7c26778e2
treed40546f6032c255fb773bb021af5ed3a6c1610a2
parentf0fcd87e74295150ec2f811801ef52835d30d3bf
iio: pressure: bmp280: Refactorize reading functions

For BMP18x, BMP28x, BME280, BMP38x the reading of the pressure
value requires an update of the t_fine variable which happens
through reading the temperature value.

So all the bmpxxx_read_press() functions of the above sensors
are internally calling the equivalent bmpxxx_read_temp() function
in order to update the t_fine value. By just looking at the code
this functionality is a bit hidden and is not easy to understand
why those channels are not independent.

This commit tries to clear these things a bit by splitting the
bmpxxx_{read/compensate}_{temp/press/humid}() to the following:

i. bmpxxx_read_{temp/press/humid}_adc(): read the raw value from
the sensor.

ii. bmpxx_calc_t_fine(): calculate the t_fine variable.

iii. bmpxxx_get_t_fine(): get the t_fine variable.

iv. bmpxxx_compensate_{temp/press/humid}(): compensate the adc
values and return the calculated value.

v. bmpxxx_read_{temp/press/humid}(): combine calls of the
aforementioned functions to return the requested value.

Suggested-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Link: https://lore.kernel.org/r/20240512230524.53990-2-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/pressure/bmp280-core.c
drivers/iio/pressure/bmp280.h