Skip to content

Commit

Permalink
spi/s3c64xx: Check for errors in dmaengine prepare_transfer()
Browse files Browse the repository at this point in the history
Don't silently ignore errors, report them.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
  • Loading branch information
Mark Brown committed Apr 18, 2013
1 parent 563b444 commit fb9d044
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion drivers/spi/spi-s3c64xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,18 +421,42 @@ static int s3c64xx_spi_prepare_transfer(struct spi_master *spi)
dma_filter_fn filter = sdd->cntrlr_info->filter;
struct device *dev = &sdd->pdev->dev;
dma_cap_mask_t mask;
int ret;

dma_cap_zero(mask);
dma_cap_set(DMA_SLAVE, mask);

/* Acquire DMA channels */
sdd->rx_dma.ch = dma_request_slave_channel_compat(mask, filter,
(void*)sdd->rx_dma.dmach, dev, "rx");
if (!sdd->rx_dma.ch) {
dev_err(dev, "Failed to get RX DMA channel\n");
ret = -EBUSY;
goto out;
}

sdd->tx_dma.ch = dma_request_slave_channel_compat(mask, filter,
(void*)sdd->tx_dma.dmach, dev, "tx");
pm_runtime_get_sync(&sdd->pdev->dev);
if (!sdd->tx_dma.ch) {
dev_err(dev, "Failed to get TX DMA channel\n");
ret = -EBUSY;
goto out_rx;
}

ret = pm_runtime_get_sync(&sdd->pdev->dev);
if (ret != 0) {
dev_err(dev, "Failed to enable device: %d\n", ret);
goto out_tx;
}

return 0;

out_tx:
dma_release_channel(sdd->tx_dma.ch);
out_rx:
dma_release_channel(sdd->rx_dma.ch);
out:
return ret;
}

static int s3c64xx_spi_unprepare_transfer(struct spi_master *spi)
Expand Down

0 comments on commit fb9d044

Please sign in to comment.