iio: imu: inv_mpu6050: use i2c mux only for chip with i2c aux bus

icm20608 does not have i2c aux bus, so it does not make sense to
allocate an i2c mux for this chip.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
Jean-Baptiste Maneyrol 2018-04-30 12:14:08 +02:00 committed by Jonathan Cameron
parent b3e5c2bda9
commit 3b37c41f0e
1 changed files with 25 additions and 16 deletions

View File

@ -125,20 +125,27 @@ static int inv_mpu_probe(struct i2c_client *client,
return result; return result;
st = iio_priv(dev_get_drvdata(&client->dev)); st = iio_priv(dev_get_drvdata(&client->dev));
st->muxc = i2c_mux_alloc(client->adapter, &client->dev, switch (st->chip_type) {
1, 0, I2C_MUX_LOCKED | I2C_MUX_GATE, case INV_ICM20608:
inv_mpu6050_select_bypass, /* no i2c auxiliary bus on the chip */
inv_mpu6050_deselect_bypass); break;
if (!st->muxc) default:
return -ENOMEM; /* declare i2c auxiliary bus */
st->muxc->priv = dev_get_drvdata(&client->dev); st->muxc = i2c_mux_alloc(client->adapter, &client->dev,
result = i2c_mux_add_adapter(st->muxc, 0, 0, 0); 1, 0, I2C_MUX_LOCKED | I2C_MUX_GATE,
if (result) inv_mpu6050_select_bypass,
return result; inv_mpu6050_deselect_bypass);
if (!st->muxc)
result = inv_mpu_acpi_create_mux_client(client); return -ENOMEM;
if (result) st->muxc->priv = dev_get_drvdata(&client->dev);
goto out_del_mux; result = i2c_mux_add_adapter(st->muxc, 0, 0, 0);
if (result)
return result;
result = inv_mpu_acpi_create_mux_client(client);
if (result)
goto out_del_mux;
break;
}
return 0; return 0;
@ -152,8 +159,10 @@ static int inv_mpu_remove(struct i2c_client *client)
struct iio_dev *indio_dev = i2c_get_clientdata(client); struct iio_dev *indio_dev = i2c_get_clientdata(client);
struct inv_mpu6050_state *st = iio_priv(indio_dev); struct inv_mpu6050_state *st = iio_priv(indio_dev);
inv_mpu_acpi_delete_mux_client(client); if (st->muxc) {
i2c_mux_del_adapters(st->muxc); inv_mpu_acpi_delete_mux_client(client);
i2c_mux_del_adapters(st->muxc);
}
return 0; return 0;
} }