* [PATCH] iio: mma8452: fix probe fail when device tree compatible is used.
@ 2022-04-25 8:41 haibo.chen
2022-05-01 16:45 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: haibo.chen @ 2022-04-25 8:41 UTC (permalink / raw)
To: jic23, lars; +Cc: haibo.chen, hdegoede, linux-iio, linux-imx
From: Haibo Chen <haibo.chen@nxp.com>
Correct the logic for the probe. First check of_match_table, if
not meet, then check i2c_driver.id_table. If both not meet, then
return fail.
Fixes: a47ac019e7e8 ("iio: mma8452: Fix probe failing when an i2c_device_id is used")
Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
---
drivers/iio/accel/mma8452.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
index 9c02c681c84c..4156d216c640 100644
--- a/drivers/iio/accel/mma8452.c
+++ b/drivers/iio/accel/mma8452.c
@@ -1556,11 +1556,13 @@ static int mma8452_probe(struct i2c_client *client,
mutex_init(&data->lock);
data->chip_info = device_get_match_data(&client->dev);
- if (!data->chip_info && id) {
- data->chip_info = &mma_chip_info_table[id->driver_data];
- } else {
- dev_err(&client->dev, "unknown device model\n");
- return -ENODEV;
+ if (!data->chip_info) {
+ if (id) {
+ data->chip_info = &mma_chip_info_table[id->driver_data];
+ } else {
+ dev_err(&client->dev, "unknown device model\n");
+ return -ENODEV;
+ }
}
ret = iio_read_mount_matrix(&client->dev, &data->orientation);
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iio: mma8452: fix probe fail when device tree compatible is used.
2022-04-25 8:41 [PATCH] iio: mma8452: fix probe fail when device tree compatible is used haibo.chen
@ 2022-05-01 16:45 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2022-05-01 16:45 UTC (permalink / raw)
To: haibo.chen; +Cc: lars, hdegoede, linux-iio, linux-imx
On Mon, 25 Apr 2022 16:41:00 +0800
haibo.chen@nxp.com wrote:
> From: Haibo Chen <haibo.chen@nxp.com>
>
> Correct the logic for the probe. First check of_match_table, if
> not meet, then check i2c_driver.id_table. If both not meet, then
> return fail.
>
> Fixes: a47ac019e7e8 ("iio: mma8452: Fix probe failing when an i2c_device_id is used")
> Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
Yikes.
Just goes to show review doesn't always pick up on the obvious :(
Applied to the fixes-togreg branch of iio.git
Jonathan
> ---
> drivers/iio/accel/mma8452.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
> index 9c02c681c84c..4156d216c640 100644
> --- a/drivers/iio/accel/mma8452.c
> +++ b/drivers/iio/accel/mma8452.c
> @@ -1556,11 +1556,13 @@ static int mma8452_probe(struct i2c_client *client,
> mutex_init(&data->lock);
>
> data->chip_info = device_get_match_data(&client->dev);
> - if (!data->chip_info && id) {
> - data->chip_info = &mma_chip_info_table[id->driver_data];
> - } else {
> - dev_err(&client->dev, "unknown device model\n");
> - return -ENODEV;
> + if (!data->chip_info) {
> + if (id) {
> + data->chip_info = &mma_chip_info_table[id->driver_data];
> + } else {
> + dev_err(&client->dev, "unknown device model\n");
> + return -ENODEV;
> + }
> }
>
> ret = iio_read_mount_matrix(&client->dev, &data->orientation);
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-05-01 16:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-25 8:41 [PATCH] iio: mma8452: fix probe fail when device tree compatible is used haibo.chen
2022-05-01 16:45 ` Jonathan Cameron
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.