mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
mpc-i2c: Propagate error values properly
Propagate the error values returned by i2c_wait() instead of overriding them with a meaningless -1. Signed-off-by: Jon Smirl <jonsmirl@gmail.com> Signed-off-by: Jean Delvare <khali@linux-fr.org>
This commit is contained in:
parent
e9f1373b64
commit
4bd28ebda2
1 changed files with 16 additions and 12 deletions
|
@ -180,7 +180,7 @@ static void mpc_i2c_stop(struct mpc_i2c *i2c)
|
||||||
static int mpc_write(struct mpc_i2c *i2c, int target,
|
static int mpc_write(struct mpc_i2c *i2c, int target,
|
||||||
const u8 * data, int length, int restart)
|
const u8 * data, int length, int restart)
|
||||||
{
|
{
|
||||||
int i;
|
int i, result;
|
||||||
unsigned timeout = i2c->adap.timeout;
|
unsigned timeout = i2c->adap.timeout;
|
||||||
u32 flags = restart ? CCR_RSTA : 0;
|
u32 flags = restart ? CCR_RSTA : 0;
|
||||||
|
|
||||||
|
@ -192,15 +192,17 @@ static int mpc_write(struct mpc_i2c *i2c, int target,
|
||||||
/* Write target byte */
|
/* Write target byte */
|
||||||
writeb((target << 1), i2c->base + MPC_I2C_DR);
|
writeb((target << 1), i2c->base + MPC_I2C_DR);
|
||||||
|
|
||||||
if (i2c_wait(i2c, timeout, 1) < 0)
|
result = i2c_wait(i2c, timeout, 1);
|
||||||
return -1;
|
if (result < 0)
|
||||||
|
return result;
|
||||||
|
|
||||||
for (i = 0; i < length; i++) {
|
for (i = 0; i < length; i++) {
|
||||||
/* Write data byte */
|
/* Write data byte */
|
||||||
writeb(data[i], i2c->base + MPC_I2C_DR);
|
writeb(data[i], i2c->base + MPC_I2C_DR);
|
||||||
|
|
||||||
if (i2c_wait(i2c, timeout, 1) < 0)
|
result = i2c_wait(i2c, timeout, 1);
|
||||||
return -1;
|
if (result < 0)
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -210,7 +212,7 @@ static int mpc_read(struct mpc_i2c *i2c, int target,
|
||||||
u8 * data, int length, int restart)
|
u8 * data, int length, int restart)
|
||||||
{
|
{
|
||||||
unsigned timeout = i2c->adap.timeout;
|
unsigned timeout = i2c->adap.timeout;
|
||||||
int i;
|
int i, result;
|
||||||
u32 flags = restart ? CCR_RSTA : 0;
|
u32 flags = restart ? CCR_RSTA : 0;
|
||||||
|
|
||||||
/* Start with MEN */
|
/* Start with MEN */
|
||||||
|
@ -221,8 +223,9 @@ static int mpc_read(struct mpc_i2c *i2c, int target,
|
||||||
/* Write target address byte - this time with the read flag set */
|
/* Write target address byte - this time with the read flag set */
|
||||||
writeb((target << 1) | 1, i2c->base + MPC_I2C_DR);
|
writeb((target << 1) | 1, i2c->base + MPC_I2C_DR);
|
||||||
|
|
||||||
if (i2c_wait(i2c, timeout, 1) < 0)
|
result = i2c_wait(i2c, timeout, 1);
|
||||||
return -1;
|
if (result < 0)
|
||||||
|
return result;
|
||||||
|
|
||||||
if (length) {
|
if (length) {
|
||||||
if (length == 1)
|
if (length == 1)
|
||||||
|
@ -234,8 +237,9 @@ static int mpc_read(struct mpc_i2c *i2c, int target,
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < length; i++) {
|
for (i = 0; i < length; i++) {
|
||||||
if (i2c_wait(i2c, timeout, 0) < 0)
|
result = i2c_wait(i2c, timeout, 0);
|
||||||
return -1;
|
if (result < 0)
|
||||||
|
return result;
|
||||||
|
|
||||||
/* Generate txack on next to last byte */
|
/* Generate txack on next to last byte */
|
||||||
if (i == length - 2)
|
if (i == length - 2)
|
||||||
|
@ -320,9 +324,9 @@ static int fsl_i2c_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
pdata = (struct fsl_i2c_platform_data *) pdev->dev.platform_data;
|
pdata = (struct fsl_i2c_platform_data *) pdev->dev.platform_data;
|
||||||
|
|
||||||
if (!(i2c = kzalloc(sizeof(*i2c), GFP_KERNEL))) {
|
i2c = kzalloc(sizeof(*i2c), GFP_KERNEL);
|
||||||
|
if (!i2c)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
|
||||||
|
|
||||||
i2c->irq = platform_get_irq(pdev, 0);
|
i2c->irq = platform_get_irq(pdev, 0);
|
||||||
if (i2c->irq < 0) {
|
if (i2c->irq < 0) {
|
||||||
|
|
Loading…
Reference in a new issue