diff options
author | Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com> | 2022-06-09 12:23:01 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-06-29 09:04:39 +0200 |
commit | 50a968ccb7694d07bb9c7d67e44dd52ec621379d (patch) | |
tree | b4aaf4542e3ae121304a365f8a1b8804cfe469a0 | |
parent | 011f3bff70c2e9efd851574cd4c08963a1aff678 (diff) | |
download | linux-stable-50a968ccb7694d07bb9c7d67e44dd52ec621379d.tar.gz linux-stable-50a968ccb7694d07bb9c7d67e44dd52ec621379d.tar.bz2 linux-stable-50a968ccb7694d07bb9c7d67e44dd52ec621379d.zip |
iio: imu: inv_icm42600: Fix broken icm42600 (chip id 0 value)
commit 106b391e1b859100a3f38f0ad874236e9be06bde upstream.
The 0 value used for INV_CHIP_ICM42600 was not working since the
match in i2c/spi was checking against NULL value.
To keep this check, add a first INV_CHIP_INVALID 0 value as safe
guard.
Fixes: 31c24c1e93c3 ("iio: imu: inv_icm42600: add core of new inv_icm42600 driver")
Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Link: https://lore.kernel.org/r/20220609102301.4794-1-jmaneyrol@invensense.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/iio/imu/inv_icm42600/inv_icm42600.h | 1 | ||||
-rw-r--r-- | drivers/iio/imu/inv_icm42600/inv_icm42600_core.c | 2 |
2 files changed, 2 insertions, 1 deletions
diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600.h b/drivers/iio/imu/inv_icm42600/inv_icm42600.h index c0f5059b13b3..995a9dc06521 100644 --- a/drivers/iio/imu/inv_icm42600/inv_icm42600.h +++ b/drivers/iio/imu/inv_icm42600/inv_icm42600.h @@ -17,6 +17,7 @@ #include "inv_icm42600_buffer.h" enum inv_icm42600_chip { + INV_CHIP_INVALID, INV_CHIP_ICM42600, INV_CHIP_ICM42602, INV_CHIP_ICM42605, diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c index 86858da9cc38..ca85fccc9839 100644 --- a/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c +++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c @@ -565,7 +565,7 @@ int inv_icm42600_core_probe(struct regmap *regmap, int chip, int irq, bool open_drain; int ret; - if (chip < 0 || chip >= INV_CHIP_NB) { + if (chip <= INV_CHIP_INVALID || chip >= INV_CHIP_NB) { dev_err(dev, "invalid chip = %d\n", chip); return -ENODEV; } |