Skip to contentSkip to conversation

iio: mma8452: fix probe fail when device tree compatible is used.

PATCH Applied [email protected] 2 participants 2 messages Apr 25, 2022 – May 1, 2022 IIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: mma8452: fix probe fail when device tree compatible is used.

From: Haibo Chen <[email protected]>

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")
---
 drivers/iio/accel/mma8452.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/iio/accel/mma8452.c +7 -5
index 9c02c681c84c..4156d216c640 100644
@@ -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);
Signature · 1 line
2.25.1
maintainer Applied
#1 lore raw
Quoted 8 lines · On Mon, 25 Apr 2022 16:41:00 +0800 [email protected] wrote:

From: Haibo Chen <[email protected]>

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")

Yikes.

Just goes to show review doesn't always pick up on the obvious :(

Applied to the fixes-togreg branch of iio.git

Jonathan

Quoted 27 lines
---
 drivers/iio/accel/mma8452.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/iio/accel/mma8452.c +7 -5
index 9c02c681c84c..4156d216c640 100644
@@ -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);