1
0
Fork 0
alistair23-linux/drivers/iio/imu/st_lsm6dsx
Stephan Gerhold 8e5164949a iio: imu: st_lsm6dsx: Fix selection of ST_LSM6DS3_ID
commit fb4fbc8904 upstream.

At the moment, attempting to probe a device with ST_LSM6DS3_ID
(e.g. using the st,lsm6ds3 compatible) fails with:

    st_lsm6dsx_i2c 1-006b: unsupported whoami [69]

... even though 0x69 is the whoami listed for ST_LSM6DS3_ID.

This happens because st_lsm6dsx_check_whoami() also attempts
to match unspecified (zero-initialized) entries in the "id" array.
ST_LSM6DS3_ID = 0 will therefore match any entry in
st_lsm6dsx_sensor_settings (here: the first), because none of them
actually have all 12 entries listed in the "id" array.

Avoid this by additionally checking if "name" is set,
which is only set for valid entries in the "id" array.

Note: Although the problem was introduced earlier it did not surface until
commit 52f4b1f196 ("iio: imu: st_lsm6dsx: add support for accel/gyro unit of lsm9ds1")
because ST_LSM6DS3_ID was the first entry in st_lsm6dsx_sensor_settings.

Fixes: d068e4a0f9 ("iio: imu: st_lsm6dsx: add support to multiple devices with the same settings")
Cc: <stable@vger.kernel.org> # 5.4
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-01-23 08:22:33 +01:00
..
Kconfig iio: imu: st_lsm6dsx: add support for accel/gyro unit of lsm9ds1 2019-09-03 18:55:50 +01:00
Makefile iio: imu: st_lsm6dsx: add i3c basic support for LSM6DSO and LSM6DSR 2019-07-27 22:55:27 +01:00
st_lsm6dsx.h iio: imu: st_lsm6dsx: forbid 0 sensor sensitivity 2019-09-08 12:35:08 +01:00
st_lsm6dsx_buffer.c iio: imu: st_lsm6dsx: introduce update_fifo function pointer 2019-08-26 08:52:03 +01:00
st_lsm6dsx_core.c iio: imu: st_lsm6dsx: Fix selection of ST_LSM6DS3_ID 2020-01-23 08:22:33 +01:00
st_lsm6dsx_i2c.c iio: imu: st_lsm6dsx: add support for accel/gyro unit of lsm9ds1 2019-09-03 18:55:50 +01:00
st_lsm6dsx_i3c.c iio: imu: st_lsm6dsx: add i3c basic support for LSM6DSO and LSM6DSR 2019-07-27 22:55:27 +01:00
st_lsm6dsx_shub.c iio: imu: st_lsm6dsx: fix waitime for st_lsm6dsx i2c controller 2019-10-09 19:11:28 +01:00
st_lsm6dsx_spi.c iio: imu: st_lsm6dsx: add support for accel/gyro unit of lsm9ds1 2019-09-03 18:55:50 +01:00