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: imu: st_lsm6dsx: Set FIFO ODR for accelerometer and gyroscope only

The st_lsm6dsx_set_fifo_odr() function, which is called when enabling and
disabling the hardware FIFO, checks the contents of the hw->settings->batch
array at index sensor->id, and then sets the current ODR value in sensor
registers that depend on whether the register address is set in the above
array element. This logic is valid for internal sensors only, i.e. the
accelerometer and gyroscope; however, since commit c91c1c844ebd ("iio: imu:
st_lsm6dsx: add i2c embedded controller support"), this function is called
also when configuring the hardware FIFO for external sensors (i.e. sensors
accessed through the sensor hub functionality), which can result in
unrelated device registers being written.

Add a check to the beginning of st_lsm6dsx_set_fifo_odr() so that it does
not touch any registers unless it is called for internal sensors.

Fixes: c91c1c844ebd ("iio: imu: st_lsm6dsx: add i2c embedded controller support")
Signed-off-by: Francesco Lavra <flavra@baylibre.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Francesco Lavra and committed by
Jonathan Cameron
630748af b403981d

+4
+4
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
··· 225 225 const struct st_lsm6dsx_reg *batch_reg; 226 226 u8 data; 227 227 228 + /* Only internal sensors have a FIFO ODR configuration register. */ 229 + if (sensor->id >= ARRAY_SIZE(hw->settings->batch)) 230 + return 0; 231 + 228 232 batch_reg = &hw->settings->batch[sensor->id]; 229 233 if (batch_reg->addr) { 230 234 int val;