aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses/i2c-sh_mobile.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c/busses/i2c-sh_mobile.c')
-rw-r--r--drivers/i2c/busses/i2c-sh_mobile.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c
index 439e8778f849..818cab14e87c 100644
--- a/drivers/i2c/busses/i2c-sh_mobile.c
+++ b/drivers/i2c/busses/i2c-sh_mobile.c
@@ -507,8 +507,6 @@ static void sh_mobile_i2c_dma_callback(void *data)
507 pd->pos = pd->msg->len; 507 pd->pos = pd->msg->len;
508 pd->stop_after_dma = true; 508 pd->stop_after_dma = true;
509 509
510 i2c_release_dma_safe_msg_buf(pd->msg, pd->dma_buf);
511
512 iic_set_clr(pd, ICIC, 0, ICIC_TDMAE | ICIC_RDMAE); 510 iic_set_clr(pd, ICIC, 0, ICIC_TDMAE | ICIC_RDMAE);
513} 511}
514 512
@@ -602,8 +600,8 @@ static void sh_mobile_i2c_xfer_dma(struct sh_mobile_i2c_data *pd)
602 dma_async_issue_pending(chan); 600 dma_async_issue_pending(chan);
603} 601}
604 602
605static int start_ch(struct sh_mobile_i2c_data *pd, struct i2c_msg *usr_msg, 603static void start_ch(struct sh_mobile_i2c_data *pd, struct i2c_msg *usr_msg,
606 bool do_init) 604 bool do_init)
607{ 605{
608 if (do_init) { 606 if (do_init) {
609 /* Initialize channel registers */ 607 /* Initialize channel registers */
@@ -627,7 +625,6 @@ static int start_ch(struct sh_mobile_i2c_data *pd, struct i2c_msg *usr_msg,
627 625
628 /* Enable all interrupts to begin with */ 626 /* Enable all interrupts to begin with */
629 iic_wr(pd, ICIC, ICIC_DTEE | ICIC_WAITE | ICIC_ALE | ICIC_TACKE); 627 iic_wr(pd, ICIC, ICIC_DTEE | ICIC_WAITE | ICIC_ALE | ICIC_TACKE);
630 return 0;
631} 628}
632 629
633static int poll_dte(struct sh_mobile_i2c_data *pd) 630static int poll_dte(struct sh_mobile_i2c_data *pd)
@@ -698,9 +695,7 @@ static int sh_mobile_i2c_xfer(struct i2c_adapter *adapter,
698 pd->send_stop = i == num - 1 || msg->flags & I2C_M_STOP; 695 pd->send_stop = i == num - 1 || msg->flags & I2C_M_STOP;
699 pd->stop_after_dma = false; 696 pd->stop_after_dma = false;
700 697
701 err = start_ch(pd, msg, do_start); 698 start_ch(pd, msg, do_start);
702 if (err)
703 break;
704 699
705 if (do_start) 700 if (do_start)
706 i2c_op(pd, OP_START, 0); 701 i2c_op(pd, OP_START, 0);
@@ -709,6 +704,10 @@ static int sh_mobile_i2c_xfer(struct i2c_adapter *adapter,
709 timeout = wait_event_timeout(pd->wait, 704 timeout = wait_event_timeout(pd->wait,
710 pd->sr & (ICSR_TACK | SW_DONE), 705 pd->sr & (ICSR_TACK | SW_DONE),
711 adapter->timeout); 706 adapter->timeout);
707
708 /* 'stop_after_dma' tells if DMA transfer was complete */
709 i2c_put_dma_safe_msg_buf(pd->dma_buf, pd->msg, pd->stop_after_dma);
710
712 if (!timeout) { 711 if (!timeout) {
713 dev_err(pd->dev, "Transfer request timed out\n"); 712 dev_err(pd->dev, "Transfer request timed out\n");
714 if (pd->dma_direction != DMA_NONE) 713 if (pd->dma_direction != DMA_NONE)