* [PATCH] iio: imu: inv_icm42600: Fix broken icm42600 (chip id 0 value)
@ 2022-06-09 10:23 Jean-Baptiste Maneyrol
2022-06-11 16:07 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: Jean-Baptiste Maneyrol @ 2022-06-09 10:23 UTC (permalink / raw)
To: jic23; +Cc: linux-iio, stable, Jean-Baptiste Maneyrol
From: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
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>
---
drivers/iio/imu/inv_icm42600/inv_icm42600.h | 1 +
drivers/iio/imu/inv_icm42600/inv_icm42600_core.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600.h b/drivers/iio/imu/inv_icm42600/inv_icm42600.h
index 62fedac54e65..3d91469beccb 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;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iio: imu: inv_icm42600: Fix broken icm42600 (chip id 0 value)
2022-06-09 10:23 [PATCH] iio: imu: inv_icm42600: Fix broken icm42600 (chip id 0 value) Jean-Baptiste Maneyrol
@ 2022-06-11 16:07 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2022-06-11 16:07 UTC (permalink / raw)
To: Jean-Baptiste Maneyrol; +Cc: linux-iio, stable, Jean-Baptiste Maneyrol
On Thu, 9 Jun 2022 12:23:01 +0200
Jean-Baptiste Maneyrol <jmaneyrol@invensense.com> wrote:
> From: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
>
> 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>
Applied to the fixes-togreg branch of iio.git.
Thanks,
Jonathan
> ---
> drivers/iio/imu/inv_icm42600/inv_icm42600.h | 1 +
> drivers/iio/imu/inv_icm42600/inv_icm42600_core.c | 2 +-
> 2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600.h b/drivers/iio/imu/inv_icm42600/inv_icm42600.h
> index 62fedac54e65..3d91469beccb 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;
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-06-11 15:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-09 10:23 [PATCH] iio: imu: inv_icm42600: Fix broken icm42600 (chip id 0 value) Jean-Baptiste Maneyrol
2022-06-11 16:07 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).