Commit fe188949 authored by Haibo Chen's avatar Haibo Chen Committed by Jonathan Cameron
Browse files

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



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: a47ac019 ("iio: mma8452: Fix probe failing when an i2c_device_id is used")
Signed-off-by: default avatarHaibo Chen <haibo.chen@nxp.com>
Link: https://lore.kernel.org/r/1650876060-17577-1-git-send-email-haibo.chen@nxp.com


Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 57ae8a49
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -1556,12 +1556,14 @@ 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) {
	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);
	if (ret)