From 05965ceb8bbc550775894a07458ec657650b0090 Mon Sep 17 00:00:00 2001 From: kfx Date: Wed, 6 Jun 2012 15:39:58 +0800 Subject: [PATCH] rk30: i2c: clk_disable(i2c->clk) when i2c-x is in idle state --- drivers/i2c/busses/i2c-rk30-adapter.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-rk30-adapter.c b/drivers/i2c/busses/i2c-rk30-adapter.c index fbb432f57d5b..f7b700b40d6a 100755 --- a/drivers/i2c/busses/i2c-rk30-adapter.c +++ b/drivers/i2c/busses/i2c-rk30-adapter.c @@ -187,6 +187,7 @@ static void rk30_i2c_init_hw(struct rk30_i2c *i2c, unsigned long scl_rate) { i2c->scl_rate = 0; rk30_i2c_set_clk(i2c, scl_rate); + clk_disable(i2c->clk); return; } /* returns TRUE if we this is the last byte in the current message */ @@ -486,7 +487,8 @@ static int rk30_i2c_doxfer(struct rk30_i2c *i2c, dev_err(i2c->dev, "addr[0x%02x] wait event timeout, state: %d, is_busy: %d, error: %d, complete_what: 0x%x\n", msgs[0].addr, i2c->state, i2c->is_busy, i2c->error, i2c->complete_what); i2c->state = STATE_IDLE; - if(i2c->error < 0) i2c->error = -ETIMEDOUT; + if((i2c->error < 0) || (i2c->is_busy != 0) || !(i2c->complete_what & (1 << STATE_STOP))) + i2c->error = -ETIMEDOUT; rk30_i2c_send_stop(i2c); } @@ -512,6 +514,8 @@ static int rk30_i2c_xfer(struct i2c_adapter *adap, unsigned long scl_rate; struct rk30_i2c *i2c = (struct rk30_i2c *)adap->algo_data; + clk_enable(i2c->clk); + if(msgs[0].scl_rate <= 400000 && msgs[0].scl_rate >= 10000) scl_rate = msgs[0].scl_rate; else if(msgs[0].scl_rate > 400000){ @@ -538,6 +542,8 @@ static int rk30_i2c_xfer(struct i2c_adapter *adap, wake_unlock(&i2c->idlelock[i2c->adap.nr]); mutex_unlock(&i2c->m_lock); } + + clk_disable(i2c->clk); return (ret < 0)?ret:num; } -- 2.34.1