diff options
author | Ludovic Desroches <ludovic.desroches@atmel.com> | 2012-02-09 10:33:53 -0500 |
---|---|---|
committer | Chris Ball <cjb@laptop.org> | 2012-03-02 16:06:40 -0500 |
commit | ef8781989a1bcd05aa47e853917c37df44917194 (patch) | |
tree | 1f888b6847938ab17be3481c813e1da60c66f34b | |
parent | 2273d5ccb882106a74c7b780a6bfa16fb210cd24 (diff) |
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: Ludovic Desroches <ludovic.desroches@atmel.com>
Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
[Should be applied to 3.2-stable.]
Cc: <stable@vger.kernel.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
-rw-r--r-- | drivers/mmc/host/atmel-mci.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c index 6985cdb0bb26..e4449a54ae8f 100644 --- a/drivers/mmc/host/atmel-mci.c +++ b/drivers/mmc/host/atmel-mci.c | |||
@@ -1948,12 +1948,12 @@ static bool atmci_filter(struct dma_chan *chan, void *slave) | |||
1948 | } | 1948 | } |
1949 | } | 1949 | } |
1950 | 1950 | ||
1951 | static void atmci_configure_dma(struct atmel_mci *host) | 1951 | static bool atmci_configure_dma(struct atmel_mci *host) |
1952 | { | 1952 | { |
1953 | struct mci_platform_data *pdata; | 1953 | struct mci_platform_data *pdata; |
1954 | 1954 | ||
1955 | if (host == NULL) | 1955 | if (host == NULL) |
1956 | return; | 1956 | return false; |
1957 | 1957 | ||
1958 | pdata = host->pdev->dev.platform_data; | 1958 | pdata = host->pdev->dev.platform_data; |
1959 | 1959 | ||
@@ -1970,12 +1970,15 @@ static void atmci_configure_dma(struct atmel_mci *host) | |||
1970 | host->dma.chan = | 1970 | host->dma.chan = |
1971 | dma_request_channel(mask, atmci_filter, pdata->dma_slave); | 1971 | dma_request_channel(mask, atmci_filter, pdata->dma_slave); |
1972 | } | 1972 | } |
1973 | if (!host->dma.chan) | 1973 | if (!host->dma.chan) { |
1974 | dev_notice(&host->pdev->dev, "DMA not available, using PIO\n"); | 1974 | dev_warn(&host->pdev->dev, "no DMA channel available\n"); |
1975 | else | 1975 | return false; |
1976 | } else { | ||
1976 | dev_info(&host->pdev->dev, | 1977 | dev_info(&host->pdev->dev, |
1977 | "Using %s for DMA transfers\n", | 1978 | "Using %s for DMA transfers\n", |
1978 | dma_chan_name(host->dma.chan)); | 1979 | dma_chan_name(host->dma.chan)); |
1980 | return true; | ||
1981 | } | ||
1979 | } | 1982 | } |
1980 | 1983 | ||
1981 | static inline unsigned int atmci_get_version(struct atmel_mci *host) | 1984 | 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 | 2088 | ||
2086 | /* Get MCI capabilities and set operations according to it */ | 2089 | /* Get MCI capabilities and set operations according to it */ |
2087 | atmci_get_cap(host); | 2090 | atmci_get_cap(host); |
2088 | if (host->caps.has_dma) { | 2091 | if (host->caps.has_dma && atmci_configure_dma(host)) { |
2089 | dev_info(&pdev->dev, "using DMA\n"); | ||
2090 | host->prepare_data = &atmci_prepare_data_dma; | 2092 | host->prepare_data = &atmci_prepare_data_dma; |
2091 | host->submit_data = &atmci_submit_data_dma; | 2093 | host->submit_data = &atmci_submit_data_dma; |
2092 | host->stop_transfer = &atmci_stop_transfer_dma; | 2094 | host->stop_transfer = &atmci_stop_transfer_dma; |
@@ -2096,15 +2098,12 @@ static int __init atmci_probe(struct platform_device *pdev) | |||
2096 | host->submit_data = &atmci_submit_data_pdc; | 2098 | host->submit_data = &atmci_submit_data_pdc; |
2097 | host->stop_transfer = &atmci_stop_transfer_pdc; | 2099 | host->stop_transfer = &atmci_stop_transfer_pdc; |
2098 | } else { | 2100 | } else { |
2099 | dev_info(&pdev->dev, "no DMA, no PDC\n"); | 2101 | dev_info(&pdev->dev, "using PIO\n"); |
2100 | host->prepare_data = &atmci_prepare_data; | 2102 | host->prepare_data = &atmci_prepare_data; |
2101 | host->submit_data = &atmci_submit_data; | 2103 | host->submit_data = &atmci_submit_data; |
2102 | host->stop_transfer = &atmci_stop_transfer; | 2104 | host->stop_transfer = &atmci_stop_transfer; |
2103 | } | 2105 | } |
2104 | 2106 | ||
2105 | if (host->caps.has_dma) | ||
2106 | atmci_configure_dma(host); | ||
2107 | |||
2108 | platform_set_drvdata(pdev, host); | 2107 | platform_set_drvdata(pdev, host); |
2109 | 2108 | ||
2110 | /* We need at least one slot to succeed */ | 2109 | /* We need at least one slot to succeed */ |