summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorTroy Kisky <troy.kisky@boundarydevices.com>2012-07-19 08:18:07 +0000
committerHeiko Schocher <hs@denx.de>2012-07-31 07:43:25 +0200
commitc4330d283cefbd3574366e82910da3e918324b86 (patch)
tree5cb0430edf47e49e65c5e4e90dfc43d807f57a76 /drivers
parentb230ddc267be2b9166421869549882d15b92e2ff (diff)
downloadu-boot-imx-c4330d283cefbd3574366e82910da3e918324b86.zip
u-boot-imx-c4330d283cefbd3574366e82910da3e918324b86.tar.gz
u-boot-imx-c4330d283cefbd3574366e82910da3e918324b86.tar.bz2
mxc_i2c: call i2c_imx_stop on error in i2c_read/i2c_write
Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/i2c/mxc_i2c.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c
index 4ce695a..55a688a 100644
--- a/drivers/i2c/mxc_i2c.c
+++ b/drivers/i2c/mxc_i2c.c
@@ -337,8 +337,10 @@ int i2c_read(uchar chip, uint addr, int alen, uchar *buf, int len)
writeb(temp, &i2c_regs->i2cr);
ret = tx_byte(i2c_regs, (chip << 1) | 1);
- if (ret < 0)
+ if (ret < 0) {
+ i2c_imx_stop();
return ret;
+ }
/* setup bus to read data */
temp = readb(&i2c_regs->i2cr);
@@ -352,8 +354,10 @@ int i2c_read(uchar chip, uint addr, int alen, uchar *buf, int len)
/* read data */
for (i = 0; i < len; i++) {
ret = i2c_imx_trx_complete();
- if (ret)
+ if (ret) {
+ i2c_imx_stop();
return ret;
+ }
/*
* It must generate STOP before read I2DR to prevent
@@ -395,7 +399,7 @@ int i2c_write(uchar chip, uint addr, int alen, uchar *buf, int len)
for (i = 0; i < len; i++) {
ret = tx_byte(i2c_regs, buf[i]);
if (ret < 0)
- return ret;
+ break;
}
i2c_imx_stop();