Commit 63151c53 authored by Fabio Estevam's avatar Fabio Estevam Committed by Wolfram Sang

i2c: mxs: Check the return value from stmp_reset_block()

stmp_reset_block() may fail, so let's check its return value and propagate it in
the case of error.
Signed-off-by: default avatarFabio Estevam <fabio.estevam@freescale.com>
Acked-by: default avatarMarek Vasut <marex@denx.de>
Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
parent 2806914f
...@@ -123,9 +123,11 @@ struct mxs_i2c_dev { ...@@ -123,9 +123,11 @@ struct mxs_i2c_dev {
bool dma_read; bool dma_read;
}; };
static void mxs_i2c_reset(struct mxs_i2c_dev *i2c) static int mxs_i2c_reset(struct mxs_i2c_dev *i2c)
{ {
stmp_reset_block(i2c->regs); int ret = stmp_reset_block(i2c->regs);
if (ret)
return ret;
/* /*
* Configure timing for the I2C block. The I2C TIMING2 register has to * Configure timing for the I2C block. The I2C TIMING2 register has to
...@@ -139,6 +141,8 @@ static void mxs_i2c_reset(struct mxs_i2c_dev *i2c) ...@@ -139,6 +141,8 @@ static void mxs_i2c_reset(struct mxs_i2c_dev *i2c)
writel(0x00300030, i2c->regs + MXS_I2C_TIMING2); writel(0x00300030, i2c->regs + MXS_I2C_TIMING2);
writel(MXS_I2C_IRQ_MASK << 8, i2c->regs + MXS_I2C_CTRL1_SET); writel(MXS_I2C_IRQ_MASK << 8, i2c->regs + MXS_I2C_CTRL1_SET);
return 0;
} }
static void mxs_i2c_dma_finish(struct mxs_i2c_dev *i2c) static void mxs_i2c_dma_finish(struct mxs_i2c_dev *i2c)
...@@ -475,7 +479,7 @@ static int mxs_i2c_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, ...@@ -475,7 +479,7 @@ static int mxs_i2c_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg,
int stop) int stop)
{ {
struct mxs_i2c_dev *i2c = i2c_get_adapdata(adap); struct mxs_i2c_dev *i2c = i2c_get_adapdata(adap);
int ret; int ret, err;
int flags; int flags;
flags = stop ? MXS_I2C_CTRL0_POST_SEND_STOP : 0; flags = stop ? MXS_I2C_CTRL0_POST_SEND_STOP : 0;
...@@ -495,8 +499,11 @@ static int mxs_i2c_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, ...@@ -495,8 +499,11 @@ static int mxs_i2c_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg,
i2c->cmd_err = 0; i2c->cmd_err = 0;
if (0) { /* disable PIO mode until a proper fix is made */ if (0) { /* disable PIO mode until a proper fix is made */
ret = mxs_i2c_pio_setup_xfer(adap, msg, flags); ret = mxs_i2c_pio_setup_xfer(adap, msg, flags);
if (ret) if (ret) {
mxs_i2c_reset(i2c); err = mxs_i2c_reset(i2c);
if (err)
return err;
}
} else { } else {
INIT_COMPLETION(i2c->cmd_complete); INIT_COMPLETION(i2c->cmd_complete);
ret = mxs_i2c_dma_setup_xfer(adap, msg, flags); ret = mxs_i2c_dma_setup_xfer(adap, msg, flags);
...@@ -527,7 +534,10 @@ static int mxs_i2c_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, ...@@ -527,7 +534,10 @@ static int mxs_i2c_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg,
timeout: timeout:
dev_dbg(i2c->dev, "Timeout!\n"); dev_dbg(i2c->dev, "Timeout!\n");
mxs_i2c_dma_finish(i2c); mxs_i2c_dma_finish(i2c);
mxs_i2c_reset(i2c); ret = mxs_i2c_reset(i2c);
if (ret)
return ret;
return -ETIMEDOUT; return -ETIMEDOUT;
} }
...@@ -683,7 +693,9 @@ static int mxs_i2c_probe(struct platform_device *pdev) ...@@ -683,7 +693,9 @@ static int mxs_i2c_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, i2c); platform_set_drvdata(pdev, i2c);
/* Do reset to enforce correct startup after pinmuxing */ /* Do reset to enforce correct startup after pinmuxing */
mxs_i2c_reset(i2c); err = mxs_i2c_reset(i2c);
if (err)
return err;
adap = &i2c->adapter; adap = &i2c->adapter;
strlcpy(adap->name, "MXS I2C adapter", sizeof(adap->name)); strlcpy(adap->name, "MXS I2C adapter", sizeof(adap->name));
......
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