]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
iio: chemical: bme680: Fix read/write ops to device by adding mutexes
authorVasileios Amoiridis <vassilisamir@gmail.com>
Sun, 9 Jun 2024 23:38:12 +0000 (01:38 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 4 Oct 2024 14:29:39 +0000 (16:29 +0200)
commit2bc96d4ea9e1310cf41d7dc062f76c8ad57849cb
tree66f8ffdb6b01c1f58b2fd3fe8f1e3738eb31e0c1
parent5d86a29db8a332d89088a4523f6c0308f7f4b938
iio: chemical: bme680: Fix read/write ops to device by adding mutexes

[ Upstream commit 77641e5a477d428335cd094b88ac54e09ccb70f4 ]

Add mutexes in the {read/write}_raw() functions of the device to guard the
read/write of data from/to the device. This is necessary because for any
operation other than temperature, multiple reads need to take place from
the device. Even though regmap has a locking by itself, it won't protect us
from multiple applications trying to read at the same time temperature and
pressure since the pressure reading includes an internal temperature
reading and there is nothing to ensure that this temperature+pressure
reading will happen sequentially without any other operation interfering
in the meantime.

Fixes: 1b3bd8592780 ("iio: chemical: Add support for Bosch BME680 sensor")
Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Link: https://patch.msgid.link/20240609233826.330516-2-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/iio/chemical/bme680_core.c