提交 5af0e07f 编写于 作者: D Domen Puncer 提交者: Jean Delvare

i2c-mpc: Don't disable I2C module on stop condition

Disabling module on stop doesn't work on some CPUs (ie. mpc8241,
as reported by Guennadi Liakhovetski), so remove that.

Disable I2C module on errors/interrupts to prevent it from
locking up on mpc5200b.
Signed-off-by: NDomen Puncer <domen.puncer@telargo.com>
Acked-by: NGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: NJean Delvare <khali@linux-fr.org>
上级 432ca994
...@@ -105,6 +105,7 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing) ...@@ -105,6 +105,7 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
schedule(); schedule();
if (time_after(jiffies, orig_jiffies + timeout)) { if (time_after(jiffies, orig_jiffies + timeout)) {
pr_debug("I2C: timeout\n"); pr_debug("I2C: timeout\n");
writeccr(i2c, 0);
result = -EIO; result = -EIO;
break; break;
} }
...@@ -116,10 +117,12 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing) ...@@ -116,10 +117,12 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
result = wait_event_interruptible_timeout(i2c->queue, result = wait_event_interruptible_timeout(i2c->queue,
(i2c->interrupt & CSR_MIF), timeout * HZ); (i2c->interrupt & CSR_MIF), timeout * HZ);
if (unlikely(result < 0)) if (unlikely(result < 0)) {
pr_debug("I2C: wait interrupted\n"); pr_debug("I2C: wait interrupted\n");
else if (unlikely(!(i2c->interrupt & CSR_MIF))) { writeccr(i2c, 0);
} else if (unlikely(!(i2c->interrupt & CSR_MIF))) {
pr_debug("I2C: wait timeout\n"); pr_debug("I2C: wait timeout\n");
writeccr(i2c, 0);
result = -ETIMEDOUT; result = -ETIMEDOUT;
} }
...@@ -172,7 +175,6 @@ static void mpc_i2c_start(struct mpc_i2c *i2c) ...@@ -172,7 +175,6 @@ static void mpc_i2c_start(struct mpc_i2c *i2c)
static void mpc_i2c_stop(struct mpc_i2c *i2c) static void mpc_i2c_stop(struct mpc_i2c *i2c)
{ {
writeccr(i2c, CCR_MEN); writeccr(i2c, CCR_MEN);
writeccr(i2c, 0);
} }
static int mpc_write(struct mpc_i2c *i2c, int target, static int mpc_write(struct mpc_i2c *i2c, int target,
...@@ -261,6 +263,7 @@ static int mpc_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) ...@@ -261,6 +263,7 @@ static int mpc_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
while (readb(i2c->base + MPC_I2C_SR) & CSR_MBB) { while (readb(i2c->base + MPC_I2C_SR) & CSR_MBB) {
if (signal_pending(current)) { if (signal_pending(current)) {
pr_debug("I2C: Interrupted\n"); pr_debug("I2C: Interrupted\n");
writeccr(i2c, 0);
return -EINTR; return -EINTR;
} }
if (time_after(jiffies, orig_jiffies + HZ)) { if (time_after(jiffies, orig_jiffies + HZ)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册