Commit 6133fed0 authored by Peter Ujfalusi's avatar Peter Ujfalusi Committed by Mark Brown

spi: bcm2835: Use dma_request_chan() instead dma_request_slave_channel()

dma_request_slave_channel() is a wrapper on top of dma_request_chan()
eating up the error code.

By using dma_request_chan() directly the driver can support deferred
probing against DMA.
Signed-off-by: default avatarPeter Ujfalusi <peter.ujfalusi@ti.com>
Link: https://lore.kernel.org/r/20191212135550.4634-4-peter.ujfalusi@ti.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 666224b4
...@@ -888,8 +888,8 @@ static void bcm2835_dma_release(struct spi_controller *ctlr, ...@@ -888,8 +888,8 @@ static void bcm2835_dma_release(struct spi_controller *ctlr,
} }
} }
static void bcm2835_dma_init(struct spi_controller *ctlr, struct device *dev, static int bcm2835_dma_init(struct spi_controller *ctlr, struct device *dev,
struct bcm2835_spi *bs) struct bcm2835_spi *bs)
{ {
struct dma_slave_config slave_config; struct dma_slave_config slave_config;
const __be32 *addr; const __be32 *addr;
...@@ -900,19 +900,24 @@ static void bcm2835_dma_init(struct spi_controller *ctlr, struct device *dev, ...@@ -900,19 +900,24 @@ static void bcm2835_dma_init(struct spi_controller *ctlr, struct device *dev,
addr = of_get_address(ctlr->dev.of_node, 0, NULL, NULL); addr = of_get_address(ctlr->dev.of_node, 0, NULL, NULL);
if (!addr) { if (!addr) {
dev_err(dev, "could not get DMA-register address - not using dma mode\n"); dev_err(dev, "could not get DMA-register address - not using dma mode\n");
goto err; /* Fall back to interrupt mode */
return 0;
} }
dma_reg_base = be32_to_cpup(addr); dma_reg_base = be32_to_cpup(addr);
/* get tx/rx dma */ /* get tx/rx dma */
ctlr->dma_tx = dma_request_slave_channel(dev, "tx"); ctlr->dma_tx = dma_request_chan(dev, "tx");
if (!ctlr->dma_tx) { if (IS_ERR(ctlr->dma_tx)) {
dev_err(dev, "no tx-dma configuration found - not using dma mode\n"); dev_err(dev, "no tx-dma configuration found - not using dma mode\n");
ret = PTR_ERR(ctlr->dma_tx);
ctlr->dma_tx = NULL;
goto err; goto err;
} }
ctlr->dma_rx = dma_request_slave_channel(dev, "rx"); ctlr->dma_rx = dma_request_chan(dev, "rx");
if (!ctlr->dma_rx) { if (IS_ERR(ctlr->dma_rx)) {
dev_err(dev, "no rx-dma configuration found - not using dma mode\n"); dev_err(dev, "no rx-dma configuration found - not using dma mode\n");
ret = PTR_ERR(ctlr->dma_rx);
ctlr->dma_rx = NULL;
goto err_release; goto err_release;
} }
...@@ -997,7 +1002,7 @@ static void bcm2835_dma_init(struct spi_controller *ctlr, struct device *dev, ...@@ -997,7 +1002,7 @@ static void bcm2835_dma_init(struct spi_controller *ctlr, struct device *dev,
/* all went well, so set can_dma */ /* all went well, so set can_dma */
ctlr->can_dma = bcm2835_spi_can_dma; ctlr->can_dma = bcm2835_spi_can_dma;
return; return 0;
err_config: err_config:
dev_err(dev, "issue configuring dma: %d - not using DMA mode\n", dev_err(dev, "issue configuring dma: %d - not using DMA mode\n",
...@@ -1005,7 +1010,14 @@ static void bcm2835_dma_init(struct spi_controller *ctlr, struct device *dev, ...@@ -1005,7 +1010,14 @@ static void bcm2835_dma_init(struct spi_controller *ctlr, struct device *dev,
err_release: err_release:
bcm2835_dma_release(ctlr, bs); bcm2835_dma_release(ctlr, bs);
err: err:
return; /*
* Only report error for deferred probing, otherwise fall back to
* interrupt mode
*/
if (ret != -EPROBE_DEFER)
ret = 0;
return ret;
} }
static int bcm2835_spi_transfer_one_poll(struct spi_controller *ctlr, static int bcm2835_spi_transfer_one_poll(struct spi_controller *ctlr,
...@@ -1317,7 +1329,9 @@ static int bcm2835_spi_probe(struct platform_device *pdev) ...@@ -1317,7 +1329,9 @@ static int bcm2835_spi_probe(struct platform_device *pdev)
clk_prepare_enable(bs->clk); clk_prepare_enable(bs->clk);
bcm2835_dma_init(ctlr, &pdev->dev, bs); err = bcm2835_dma_init(ctlr, &pdev->dev, bs);
if (err)
goto out_clk_disable;
/* initialise the hardware with the default polarities */ /* initialise the hardware with the default polarities */
bcm2835_wr(bs, BCM2835_SPI_CS, bcm2835_wr(bs, BCM2835_SPI_CS,
......
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