aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses
diff options
context:
space:
mode:
authorShinya Kuribayashi <shinya.kuribayashi@necel.com>2009-11-06 07:47:30 -0500
committerBen Dooks <ben-linux@fluff.org>2009-12-08 19:19:10 -0500
commitc70c5cd37413c3fa3503212d26ffdf6df535c9de (patch)
tree4300e286c5f0d30138404217679d08729a45a1d7 /drivers/i2c/busses
parentd60c7e81dda2041302791c6a5261bd0c74d60fba (diff)
i2c-designware: i2c_dw_xfer_msg: Fix i2c_msg search bug
In case a work-in-progress i2c_msg has more bytes to be written, we need to set STATUS_WRITE_IN_PROGRESS and exit from the msg_write_idx- searching loop. Otherwise, we will overtake the current msg_write_idx without waiting for its transmission to be processed. Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi@necel.com> Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'drivers/i2c/busses')
-rw-r--r--drivers/i2c/busses/i2c-designware.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/drivers/i2c/busses/i2c-designware.c b/drivers/i2c/busses/i2c-designware.c
index cdfd94e41ccc..bfb42f0f87a6 100644
--- a/drivers/i2c/busses/i2c-designware.c
+++ b/drivers/i2c/busses/i2c-designware.c
@@ -338,6 +338,8 @@ i2c_dw_xfer_msg(struct dw_i2c_dev *dev)
338 u32 addr = msgs[dev->msg_write_idx].addr; 338 u32 addr = msgs[dev->msg_write_idx].addr;
339 u32 buf_len = dev->tx_buf_len; 339 u32 buf_len = dev->tx_buf_len;
340 340
341 intr_mask = DW_IC_INTR_STOP_DET | DW_IC_INTR_TX_ABRT;
342
341 if (!(dev->status & STATUS_WRITE_IN_PROGRESS)) { 343 if (!(dev->status & STATUS_WRITE_IN_PROGRESS)) {
342 /* Disable the adapter */ 344 /* Disable the adapter */
343 writel(0, dev->base + DW_IC_ENABLE); 345 writel(0, dev->base + DW_IC_ENABLE);
@@ -387,17 +389,19 @@ i2c_dw_xfer_msg(struct dw_i2c_dev *dev)
387 dev->base + DW_IC_DATA_CMD); 389 dev->base + DW_IC_DATA_CMD);
388 tx_limit--; buf_len--; 390 tx_limit--; buf_len--;
389 } 391 }
392
393 dev->tx_buf_len = buf_len;
394
395 if (buf_len > 0) {
396 /* more bytes to be written */
397 intr_mask |= DW_IC_INTR_TX_EMPTY;
398 dev->status |= STATUS_WRITE_IN_PROGRESS;
399 break;
400 } else
401 dev->status &= ~STATUS_WRITE_IN_PROGRESS;
390 } 402 }
391 403
392 intr_mask = DW_IC_INTR_STOP_DET | DW_IC_INTR_TX_ABRT;
393 if (buf_len > 0) { /* more bytes to be written */
394 intr_mask |= DW_IC_INTR_TX_EMPTY;
395 dev->status |= STATUS_WRITE_IN_PROGRESS;
396 } else
397 dev->status &= ~STATUS_WRITE_IN_PROGRESS;
398 writel(intr_mask, dev->base + DW_IC_INTR_MASK); 404 writel(intr_mask, dev->base + DW_IC_INTR_MASK);
399
400 dev->tx_buf_len = buf_len;
401} 405}
402 406
403static void 407static void