[PATCH 10/10] i2c: pca954x: get rid of the i2c deadlock workaround
From: Peter Rosin
Date: Mon Jan 04 2016 - 10:11:48 EST
From: Peter Rosin <peda@xxxxxxxxxx>
Signed-off-by: Peter Rosin <peda@xxxxxxxxxx>
---
drivers/i2c/muxes/i2c-mux-pca954x.c | 32 ++++++++++----------------------
1 file changed, 10 insertions(+), 22 deletions(-)
diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c
index bd89da42b417..929ce28bc657 100644
--- a/drivers/i2c/muxes/i2c-mux-pca954x.c
+++ b/drivers/i2c/muxes/i2c-mux-pca954x.c
@@ -119,32 +119,19 @@ static const struct i2c_device_id pca954x_id[] = {
};
MODULE_DEVICE_TABLE(i2c, pca954x_id);
-/* Write to mux register. Don't use i2c_transfer()/i2c_smbus_xfer()
- for this as they will try to lock adapter a second time */
static int pca954x_reg_write(struct i2c_adapter *adap,
struct i2c_client *client, u8 val)
{
- int ret = -ENODEV;
-
- if (adap->algo->master_xfer) {
- struct i2c_msg msg;
- char buf[1];
-
- msg.addr = client->addr;
- msg.flags = 0;
- msg.len = 1;
- buf[0] = val;
- msg.buf = buf;
- ret = __i2c_transfer(adap, &msg, 1);
- } else {
- union i2c_smbus_data data;
- ret = adap->algo->smbus_xfer(adap, client->addr,
- client->flags,
- I2C_SMBUS_WRITE,
- val, I2C_SMBUS_BYTE, &data);
- }
+ union i2c_smbus_data data;
- return ret;
+ if (i2c_check_functionality(adap, I2C_FUNC_SMBUS_QUICK))
+ return i2c_smbus_xfer(adap, client->addr, client->flags,
+ I2C_SMBUS_WRITE, val,
+ I2C_SMBUS_QUICK, NULL);
+ else
+ return i2c_smbus_xfer(adap, client->addr, client->flags,
+ I2C_SMBUS_WRITE, val,
+ I2C_SMBUS_BYTE, &data);
}
static int pca954x_select_chan(struct i2c_mux_core *muxc, u32 chan)
@@ -227,6 +214,7 @@ static int pca954x_probe(struct i2c_client *client,
return -ENODEV;
}
+ muxc->i2c_controlled = true;
muxc->parent = adap;
muxc->select = pca954x_select_chan;
muxc->deselect = pca954x_deselect_mux;
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/