Re: [PATCH 10/10] i2c: pca954x: get rid of the i2c deadlock workaround

2016-01-04 Thread Peter Rosin
On 2016-01-04 16:19, Lars-Peter Clausen wrote:
> On 01/04/2016 04:10 PM, Peter Rosin wrote:
>> From: Peter Rosin 
>>
>> Signed-off-by: Peter Rosin 
> 
> It would be quite good if the commit messaged said why it is now safe to
> remove the workaround.

Right, hmm, the two last patches seemed obvious at the time I wrote them,
but now I see a problem.

E.g. if two pca954x devices that depends on being idle when client devices
are not accessed happen to sit on the same bus (perhaps because the muxes
are used to hide a bunch of identical devices), it is indeed not safe to
make this change.

Thanks for making my think, and consider 9/10 and 10/10 dropped.

Cheers,
Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 10/10] i2c: pca954x: get rid of the i2c deadlock workaround

2016-01-04 Thread Lars-Peter Clausen
On 01/04/2016 04:10 PM, Peter Rosin wrote:
> From: Peter Rosin 
> 
> Signed-off-by: Peter Rosin 

It would be quite good if the commit messaged said why it is now safe to
remove the workaround.

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/10] i2c: pca954x: get rid of the i2c deadlock workaround

2016-01-04 Thread Peter Rosin
From: Peter Rosin 

Signed-off-by: Peter Rosin 
---
 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-i2c" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html