Commit ef878198 authored by Ludovic Desroches's avatar Ludovic Desroches Committed by Chris Ball

mmc: atmel-mci: don't use dma features when using DMA with no chan available

Some callbacks are set too early -- i.e. we can have dma capabilities but
we can't get a dma channel. So wait to get the dma channel before setting
callbacks and change logs consequently.
Signed-off-by: default avatarLudovic Desroches <ludovic.desroches@atmel.com>
Signed-off-by: default avatarNicolas Ferre <nicolas.ferre@atmel.com>
[Should be applied to 3.2-stable.]
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarChris Ball <cjb@laptop.org>
parent 2273d5cc
...@@ -1948,12 +1948,12 @@ static bool atmci_filter(struct dma_chan *chan, void *slave) ...@@ -1948,12 +1948,12 @@ static bool atmci_filter(struct dma_chan *chan, void *slave)
} }
} }
static void atmci_configure_dma(struct atmel_mci *host) static bool atmci_configure_dma(struct atmel_mci *host)
{ {
struct mci_platform_data *pdata; struct mci_platform_data *pdata;
if (host == NULL) if (host == NULL)
return; return false;
pdata = host->pdev->dev.platform_data; pdata = host->pdev->dev.platform_data;
...@@ -1970,12 +1970,15 @@ static void atmci_configure_dma(struct atmel_mci *host) ...@@ -1970,12 +1970,15 @@ static void atmci_configure_dma(struct atmel_mci *host)
host->dma.chan = host->dma.chan =
dma_request_channel(mask, atmci_filter, pdata->dma_slave); dma_request_channel(mask, atmci_filter, pdata->dma_slave);
} }
if (!host->dma.chan) if (!host->dma.chan) {
dev_notice(&host->pdev->dev, "DMA not available, using PIO\n"); dev_warn(&host->pdev->dev, "no DMA channel available\n");
else return false;
} else {
dev_info(&host->pdev->dev, dev_info(&host->pdev->dev,
"Using %s for DMA transfers\n", "Using %s for DMA transfers\n",
dma_chan_name(host->dma.chan)); dma_chan_name(host->dma.chan));
return true;
}
} }
static inline unsigned int atmci_get_version(struct atmel_mci *host) static inline unsigned int atmci_get_version(struct atmel_mci *host)
...@@ -2085,8 +2088,7 @@ static int __init atmci_probe(struct platform_device *pdev) ...@@ -2085,8 +2088,7 @@ static int __init atmci_probe(struct platform_device *pdev)
/* Get MCI capabilities and set operations according to it */ /* Get MCI capabilities and set operations according to it */
atmci_get_cap(host); atmci_get_cap(host);
if (host->caps.has_dma) { if (host->caps.has_dma && atmci_configure_dma(host)) {
dev_info(&pdev->dev, "using DMA\n");
host->prepare_data = &atmci_prepare_data_dma; host->prepare_data = &atmci_prepare_data_dma;
host->submit_data = &atmci_submit_data_dma; host->submit_data = &atmci_submit_data_dma;
host->stop_transfer = &atmci_stop_transfer_dma; host->stop_transfer = &atmci_stop_transfer_dma;
...@@ -2096,15 +2098,12 @@ static int __init atmci_probe(struct platform_device *pdev) ...@@ -2096,15 +2098,12 @@ static int __init atmci_probe(struct platform_device *pdev)
host->submit_data = &atmci_submit_data_pdc; host->submit_data = &atmci_submit_data_pdc;
host->stop_transfer = &atmci_stop_transfer_pdc; host->stop_transfer = &atmci_stop_transfer_pdc;
} else { } else {
dev_info(&pdev->dev, "no DMA, no PDC\n"); dev_info(&pdev->dev, "using PIO\n");
host->prepare_data = &atmci_prepare_data; host->prepare_data = &atmci_prepare_data;
host->submit_data = &atmci_submit_data; host->submit_data = &atmci_submit_data;
host->stop_transfer = &atmci_stop_transfer; host->stop_transfer = &atmci_stop_transfer;
} }
if (host->caps.has_dma)
atmci_configure_dma(host);
platform_set_drvdata(pdev, host); platform_set_drvdata(pdev, host);
/* We need at least one slot to succeed */ /* We need at least one slot to succeed */
......
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