Commit 293ff9af authored by Russell King's avatar Russell King Committed by Greg Kroah-Hartman

[PATCH] I2C: Fix i2c_use_client()

i2c_use_client() contains a bogosity.  If i2c_inc_use_client() returns
success, i2c_use_client() returns an error.  If i2c_inc_use_client()
fails, i2c_use_client() might succeed.

Fix it so that (a) we get the correct sense between these two functions,
and (b) propagate the error code from i2c_inc_use_client(), rather than
making our own one up.
parent 7fcd561a
...@@ -437,8 +437,11 @@ static void i2c_dec_use_client(struct i2c_client *client) ...@@ -437,8 +437,11 @@ static void i2c_dec_use_client(struct i2c_client *client)
int i2c_use_client(struct i2c_client *client) int i2c_use_client(struct i2c_client *client)
{ {
if (!i2c_inc_use_client(client)) int ret;
return -ENODEV;
ret = i2c_inc_use_client(client);
if (ret)
return ret;
if (client->flags & I2C_CLIENT_ALLOW_USE) { if (client->flags & I2C_CLIENT_ALLOW_USE) {
if (client->flags & I2C_CLIENT_ALLOW_MULTIPLE_USE) if (client->flags & I2C_CLIENT_ALLOW_MULTIPLE_USE)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment