Commit 147e0847 authored by Amit Kucheria's avatar Amit Kucheria Committed by Samuel Ortiz

mfd: Clarify twl4030 return value for read and write

We should be checking if all the messages were tranferred. If not, then we
should propagate the i2c core error code or EIO.
Currently we return success (0) even if none of messages were transferred
successfully.
Signed-off-by: default avatarAmit Kucheria <amit.kucheria@verdurent.com>
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent ab4abe05
...@@ -306,10 +306,17 @@ int twl4030_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes) ...@@ -306,10 +306,17 @@ int twl4030_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
ret = i2c_transfer(twl->client->adapter, twl->xfer_msg, 1); ret = i2c_transfer(twl->client->adapter, twl->xfer_msg, 1);
mutex_unlock(&twl->xfer_lock); mutex_unlock(&twl->xfer_lock);
/* i2cTransfer returns num messages.translate it pls.. */ /* i2c_transfer returns number of messages transferred */
if (ret >= 0) if (ret != 1) {
ret = 0; pr_err("%s: i2c_write failed to transfer all messages\n",
return ret; DRIVER_NAME);
if (ret < 0)
return ret;
else
return -EIO;
} else {
return 0;
}
} }
EXPORT_SYMBOL(twl4030_i2c_write); EXPORT_SYMBOL(twl4030_i2c_write);
...@@ -358,10 +365,17 @@ int twl4030_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes) ...@@ -358,10 +365,17 @@ int twl4030_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
ret = i2c_transfer(twl->client->adapter, twl->xfer_msg, 2); ret = i2c_transfer(twl->client->adapter, twl->xfer_msg, 2);
mutex_unlock(&twl->xfer_lock); mutex_unlock(&twl->xfer_lock);
/* i2cTransfer returns num messages.translate it pls.. */ /* i2c_transfer returns number of messages transferred */
if (ret >= 0) if (ret != 2) {
ret = 0; pr_err("%s: i2c_read failed to transfer all messages\n",
return ret; DRIVER_NAME);
if (ret < 0)
return ret;
else
return -EIO;
} else {
return 0;
}
} }
EXPORT_SYMBOL(twl4030_i2c_read); EXPORT_SYMBOL(twl4030_i2c_read);
......
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