]> www.infradead.org Git - users/jedix/linux-maple.git/commit
iio: chemical: bme680: Refactorize reading functions
authorVasileios Amoiridis <vassilisamir@gmail.com>
Sun, 9 Jun 2024 23:38:26 +0000 (01:38 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 3 Aug 2024 09:13:35 +0000 (10:13 +0100)
commitd2651a43f375d2ec849ebfa6ba2c7c2a82c8938a
tree74f785f0d7b24a57dea0e84473b42b3a8630885c
parented4bb53c467f3b8fd11a0394f72d78575f28ad3f
iio: chemical: bme680: Refactorize reading functions

The reading of the pressure and humidity value, requires an update of the
t_fine variable which happens by reading the temperature value.

So the bme680_read_{press/humid}() functions of the above sensors are
internally calling the equivalent bme680_read_temp() function in order to
update the t_fine value. By just looking at the code this relation is a
bit hidden and is not easy to understand why those channels are not
independent.

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

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

ii. bme680_calc_t_fine(): calculate the t_fine variable.

iii. bme680_get_t_fine(): get the t_fine variable.

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

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

Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Link: https://patch.msgid.link/20240609233826.330516-16-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/chemical/bme680_core.c