summaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-atmel.c
diff options
context:
space:
mode:
authorLudovic Desroches <ludovic.desroches@atmel.com>2014-11-14 11:12:54 -0500
committerMark Brown <broonie@kernel.org>2014-11-24 13:57:37 -0500
commit5e9af37e46bceea9f950d2f2ae769f1aa6b6d7a6 (patch)
treeb84f57b2f8d55233718e9be05795e1e61853ac25 /drivers/spi/spi-atmel.c
parent7758e390699fb25bf91642d52734200db38e764b (diff)
spi: atmel: introduce probe deferring
Return probe defer if requesting a dma channel without a dma controller probed. Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi/spi-atmel.c')
-rw-r--r--drivers/spi/spi-atmel.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
index 3370a3dfd883..e4193ccc4970 100644
--- a/drivers/spi/spi-atmel.c
+++ b/drivers/spi/spi-atmel.c
@@ -427,14 +427,23 @@ static int atmel_spi_configure_dma(struct atmel_spi *as)
427 dma_cap_zero(mask); 427 dma_cap_zero(mask);
428 dma_cap_set(DMA_SLAVE, mask); 428 dma_cap_set(DMA_SLAVE, mask);
429 429
430 as->dma.chan_tx = dma_request_slave_channel(dev, "tx"); 430 as->dma.chan_tx = dma_request_slave_channel_reason(dev, "tx");
431 if (!as->dma.chan_tx) { 431 if (IS_ERR(as->dma.chan_tx)) {
432 err = PTR_ERR(as->dma.chan_tx);
433 if (err == -EPROBE_DEFER) {
434 dev_warn(dev, "no DMA channel available at the moment\n");
435 return err;
436 }
432 dev_err(dev, 437 dev_err(dev,
433 "DMA TX channel not available, SPI unable to use DMA\n"); 438 "DMA TX channel not available, SPI unable to use DMA\n");
434 err = -EBUSY; 439 err = -EBUSY;
435 goto error; 440 goto error;
436 } 441 }
437 442
443 /*
444 * No reason to check EPROBE_DEFER here since we have already requested
445 * tx channel. If it fails here, it's for another reason.
446 */
438 as->dma.chan_rx = dma_request_slave_channel(dev, "rx"); 447 as->dma.chan_rx = dma_request_slave_channel(dev, "rx");
439 448
440 if (!as->dma.chan_rx) { 449 if (!as->dma.chan_rx) {
@@ -456,7 +465,7 @@ static int atmel_spi_configure_dma(struct atmel_spi *as)
456error: 465error:
457 if (as->dma.chan_rx) 466 if (as->dma.chan_rx)
458 dma_release_channel(as->dma.chan_rx); 467 dma_release_channel(as->dma.chan_rx);
459 if (as->dma.chan_tx) 468 if (!IS_ERR(as->dma.chan_tx))
460 dma_release_channel(as->dma.chan_tx); 469 dma_release_channel(as->dma.chan_tx);
461 return err; 470 return err;
462} 471}
@@ -1328,8 +1337,11 @@ static int atmel_spi_probe(struct platform_device *pdev)
1328 as->use_dma = false; 1337 as->use_dma = false;
1329 as->use_pdc = false; 1338 as->use_pdc = false;
1330 if (as->caps.has_dma_support) { 1339 if (as->caps.has_dma_support) {
1331 if (atmel_spi_configure_dma(as) == 0) 1340 ret = atmel_spi_configure_dma(as);
1341 if (ret == 0)
1332 as->use_dma = true; 1342 as->use_dma = true;
1343 else if (ret == -EPROBE_DEFER)
1344 return ret;
1333 } else { 1345 } else {
1334 as->use_pdc = true; 1346 as->use_pdc = true;
1335 } 1347 }