aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/i2c/busses/i2c-at91.c49
1 files changed, 25 insertions, 24 deletions
diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index 2fcd2755233d..6bb839b688be 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -605,11 +605,16 @@ static const struct of_device_id atmel_twi_dt_ids[] = {
605MODULE_DEVICE_TABLE(of, atmel_twi_dt_ids); 605MODULE_DEVICE_TABLE(of, atmel_twi_dt_ids);
606#endif 606#endif
607 607
608static bool filter(struct dma_chan *chan, void *slave) 608static bool filter(struct dma_chan *chan, void *pdata)
609{ 609{
610 struct at_dma_slave *sl = slave; 610 struct at91_twi_pdata *sl_pdata = pdata;
611 struct at_dma_slave *sl;
611 612
612 if (sl->dma_dev == chan->device->dev) { 613 if (!sl_pdata)
614 return false;
615
616 sl = &sl_pdata->dma_slave;
617 if (sl && (sl->dma_dev == chan->device->dev)) {
613 chan->private = sl; 618 chan->private = sl;
614 return true; 619 return true;
615 } else { 620 } else {
@@ -620,11 +625,10 @@ static bool filter(struct dma_chan *chan, void *slave)
620static int at91_twi_configure_dma(struct at91_twi_dev *dev, u32 phy_addr) 625static int at91_twi_configure_dma(struct at91_twi_dev *dev, u32 phy_addr)
621{ 626{
622 int ret = 0; 627 int ret = 0;
623 struct at_dma_slave *sdata; 628 struct at91_twi_pdata *pdata = dev->pdata;
624 struct dma_slave_config slave_config; 629 struct dma_slave_config slave_config;
625 struct at91_twi_dma *dma = &dev->dma; 630 struct at91_twi_dma *dma = &dev->dma;
626 631 dma_cap_mask_t mask;
627 sdata = &dev->pdata->dma_slave;
628 632
629 memset(&slave_config, 0, sizeof(slave_config)); 633 memset(&slave_config, 0, sizeof(slave_config));
630 slave_config.src_addr = (dma_addr_t)phy_addr + AT91_TWI_RHR; 634 slave_config.src_addr = (dma_addr_t)phy_addr + AT91_TWI_RHR;
@@ -635,25 +639,22 @@ static int at91_twi_configure_dma(struct at91_twi_dev *dev, u32 phy_addr)
635 slave_config.dst_maxburst = 1; 639 slave_config.dst_maxburst = 1;
636 slave_config.device_fc = false; 640 slave_config.device_fc = false;
637 641
638 if (sdata && sdata->dma_dev) { 642 dma_cap_zero(mask);
639 dma_cap_mask_t mask; 643 dma_cap_set(DMA_SLAVE, mask);
640 644
641 dma_cap_zero(mask); 645 dma->chan_tx = dma_request_slave_channel_compat(mask, filter, pdata,
642 dma_cap_set(DMA_SLAVE, mask); 646 dev->dev, "tx");
643 dma->chan_tx = dma_request_channel(mask, filter, sdata); 647 if (!dma->chan_tx) {
644 if (!dma->chan_tx) { 648 dev_err(dev->dev, "can't get a DMA channel for tx\n");
645 dev_err(dev->dev, "no DMA channel available for tx\n"); 649 ret = -EBUSY;
646 ret = -EBUSY; 650 goto error;
647 goto error; 651 }
648 } 652
649 dma->chan_rx = dma_request_channel(mask, filter, sdata); 653 dma->chan_rx = dma_request_slave_channel_compat(mask, filter, pdata,
650 if (!dma->chan_rx) { 654 dev->dev, "rx");
651 dev_err(dev->dev, "no DMA channel available for rx\n"); 655 if (!dma->chan_rx) {
652 ret = -EBUSY; 656 dev_err(dev->dev, "can't get a DMA channel for rx\n");
653 goto error; 657 ret = -EBUSY;
654 }
655 } else {
656 ret = -EINVAL;
657 goto error; 658 goto error;
658 } 659 }
659 660