aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorWolfram Sang <wsa+renesas@sang-engineering.com>2014-11-19 07:43:22 -0500
committerWolfram Sang <wsa@the-dreams.de>2014-11-19 09:17:16 -0500
commit8cfcae9f0595bf0d145a67cfaa1051804a301d7c (patch)
treedcfbd3389d3a03ee991cbdd8d95b6e02374deb65 /drivers/i2c
parentf5084933673e57d38492198f04b0e81b6d00dfb2 (diff)
i2c: sh_mobile: use proper device for mapping DMA memory
It should be the DMA device, not the platform device. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Acked-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/busses/i2c-sh_mobile.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c
index 92c7f7b56bdf..c7f36c1ce688 100644
--- a/drivers/i2c/busses/i2c-sh_mobile.c
+++ b/drivers/i2c/busses/i2c-sh_mobile.c
@@ -507,6 +507,17 @@ static irqreturn_t sh_mobile_i2c_isr(int irq, void *dev_id)
507 return IRQ_HANDLED; 507 return IRQ_HANDLED;
508} 508}
509 509
510static void sh_mobile_i2c_dma_unmap(struct sh_mobile_i2c_data *pd)
511{
512 struct dma_chan *chan = pd->dma_direction == DMA_FROM_DEVICE
513 ? pd->dma_rx : pd->dma_tx;
514
515 dma_unmap_single(chan->device->dev, sg_dma_address(&pd->sg),
516 pd->msg->len, pd->dma_direction);
517
518 pd->dma_direction = DMA_NONE;
519}
520
510static void sh_mobile_i2c_cleanup_dma(struct sh_mobile_i2c_data *pd) 521static void sh_mobile_i2c_cleanup_dma(struct sh_mobile_i2c_data *pd)
511{ 522{
512 if (pd->dma_direction == DMA_NONE) 523 if (pd->dma_direction == DMA_NONE)
@@ -516,20 +527,14 @@ static void sh_mobile_i2c_cleanup_dma(struct sh_mobile_i2c_data *pd)
516 else if (pd->dma_direction == DMA_TO_DEVICE) 527 else if (pd->dma_direction == DMA_TO_DEVICE)
517 dmaengine_terminate_all(pd->dma_tx); 528 dmaengine_terminate_all(pd->dma_tx);
518 529
519 dma_unmap_single(pd->dev, sg_dma_address(&pd->sg), 530 sh_mobile_i2c_dma_unmap(pd);
520 pd->msg->len, pd->dma_direction);
521
522 pd->dma_direction = DMA_NONE;
523} 531}
524 532
525static void sh_mobile_i2c_dma_callback(void *data) 533static void sh_mobile_i2c_dma_callback(void *data)
526{ 534{
527 struct sh_mobile_i2c_data *pd = data; 535 struct sh_mobile_i2c_data *pd = data;
528 536
529 dma_unmap_single(pd->dev, sg_dma_address(&pd->sg), 537 sh_mobile_i2c_dma_unmap(pd);
530 pd->msg->len, pd->dma_direction);
531
532 pd->dma_direction = DMA_NONE;
533 pd->pos = pd->msg->len; 538 pd->pos = pd->msg->len;
534 539
535 iic_set_clr(pd, ICIC, 0, ICIC_TDMAE | ICIC_RDMAE); 540 iic_set_clr(pd, ICIC, 0, ICIC_TDMAE | ICIC_RDMAE);
@@ -547,7 +552,7 @@ static void sh_mobile_i2c_xfer_dma(struct sh_mobile_i2c_data *pd)
547 if (!chan) 552 if (!chan)
548 return; 553 return;
549 554
550 dma_addr = dma_map_single(pd->dev, pd->msg->buf, pd->msg->len, dir); 555 dma_addr = dma_map_single(chan->device->dev, pd->msg->buf, pd->msg->len, dir);
551 if (dma_mapping_error(pd->dev, dma_addr)) { 556 if (dma_mapping_error(pd->dev, dma_addr)) {
552 dev_dbg(pd->dev, "dma map failed, using PIO\n"); 557 dev_dbg(pd->dev, "dma map failed, using PIO\n");
553 return; 558 return;