Commit 0470f68e authored by Mark Brown's avatar Mark Brown

Merge remote-tracking branch 'spi/topic/atmel' into spi-next

parents 77ba6145 2f767a9f
...@@ -424,10 +424,15 @@ static int atmel_spi_dma_slave_config(struct atmel_spi *as, ...@@ -424,10 +424,15 @@ static int atmel_spi_dma_slave_config(struct atmel_spi *as,
return err; return err;
} }
static bool filter(struct dma_chan *chan, void *slave) static bool filter(struct dma_chan *chan, void *pdata)
{ {
struct at_dma_slave *sl = slave; struct atmel_spi_dma *sl_pdata = pdata;
struct at_dma_slave *sl;
if (!sl_pdata)
return false;
sl = &sl_pdata->dma_slave;
if (sl->dma_dev == chan->device->dev) { if (sl->dma_dev == chan->device->dev) {
chan->private = sl; chan->private = sl;
return true; return true;
...@@ -438,24 +443,31 @@ static bool filter(struct dma_chan *chan, void *slave) ...@@ -438,24 +443,31 @@ static bool filter(struct dma_chan *chan, void *slave)
static int atmel_spi_configure_dma(struct atmel_spi *as) static int atmel_spi_configure_dma(struct atmel_spi *as)
{ {
struct at_dma_slave *sdata = &as->dma.dma_slave;
struct dma_slave_config slave_config; struct dma_slave_config slave_config;
struct device *dev = &as->pdev->dev;
int err; int err;
if (sdata && sdata->dma_dev) { dma_cap_mask_t mask;
dma_cap_mask_t mask; dma_cap_zero(mask);
dma_cap_set(DMA_SLAVE, mask);
/* Try to grab two DMA channels */ as->dma.chan_tx = dma_request_slave_channel_compat(mask, filter,
dma_cap_zero(mask); &as->dma,
dma_cap_set(DMA_SLAVE, mask); dev, "tx");
as->dma.chan_tx = dma_request_channel(mask, filter, sdata); if (!as->dma.chan_tx) {
if (as->dma.chan_tx) dev_err(dev,
as->dma.chan_rx = "DMA TX channel not available, SPI unable to use DMA\n");
dma_request_channel(mask, filter, sdata); err = -EBUSY;
goto error;
} }
if (!as->dma.chan_rx || !as->dma.chan_tx) {
dev_err(&as->pdev->dev, as->dma.chan_rx = dma_request_slave_channel_compat(mask, filter,
"DMA channel not available, SPI unable to use DMA\n"); &as->dma,
dev, "rx");
if (!as->dma.chan_rx) {
dev_err(dev,
"DMA RX channel not available, SPI unable to use DMA\n");
err = -EBUSY; err = -EBUSY;
goto error; goto error;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment