Merge tag 'driver-core-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-block.git] / drivers / spi / spi-atmel.c
index 3370a3dfd883a50b0006afda784fa1ebc7e10f5d..23d8f5f56579a83d21040ff8625e69c0c554da3b 100644 (file)
@@ -427,14 +427,23 @@ static int atmel_spi_configure_dma(struct atmel_spi *as)
        dma_cap_zero(mask);
        dma_cap_set(DMA_SLAVE, mask);
 
-       as->dma.chan_tx = dma_request_slave_channel(dev, "tx");
-       if (!as->dma.chan_tx) {
+       as->dma.chan_tx = dma_request_slave_channel_reason(dev, "tx");
+       if (IS_ERR(as->dma.chan_tx)) {
+               err = PTR_ERR(as->dma.chan_tx);
+               if (err == -EPROBE_DEFER) {
+                       dev_warn(dev, "no DMA channel available at the moment\n");
+                       return err;
+               }
                dev_err(dev,
                        "DMA TX channel not available, SPI unable to use DMA\n");
                err = -EBUSY;
                goto error;
        }
 
+       /*
+        * No reason to check EPROBE_DEFER here since we have already requested
+        * tx channel. If it fails here, it's for another reason.
+        */
        as->dma.chan_rx = dma_request_slave_channel(dev, "rx");
 
        if (!as->dma.chan_rx) {
@@ -456,7 +465,7 @@ static int atmel_spi_configure_dma(struct atmel_spi *as)
 error:
        if (as->dma.chan_rx)
                dma_release_channel(as->dma.chan_rx);
-       if (as->dma.chan_tx)
+       if (!IS_ERR(as->dma.chan_tx))
                dma_release_channel(as->dma.chan_tx);
        return err;
 }
@@ -1328,8 +1337,11 @@ static int atmel_spi_probe(struct platform_device *pdev)
        as->use_dma = false;
        as->use_pdc = false;
        if (as->caps.has_dma_support) {
-               if (atmel_spi_configure_dma(as) == 0)
+               ret = atmel_spi_configure_dma(as);
+               if (ret == 0)
                        as->use_dma = true;
+               else if (ret == -EPROBE_DEFER)
+                       return ret;
        } else {
                as->use_pdc = true;
        }
@@ -1510,7 +1522,6 @@ MODULE_DEVICE_TABLE(of, atmel_spi_dt_ids);
 static struct platform_driver atmel_spi_driver = {
        .driver         = {
                .name   = "atmel_spi",
-               .owner  = THIS_MODULE,
                .pm     = ATMEL_SPI_PM_OPS,
                .of_match_table = of_match_ptr(atmel_spi_dt_ids),
        },