aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc
diff options
context:
space:
mode:
authorPaulius Zaleckas <paulius.zaleckas@teltonika.lt>2008-07-09 09:03:20 -0400
committerPierre Ossman <drzeus@drzeus.cx>2008-07-26 19:26:16 -0400
commitc5d5e9c40fc6cabedd5fdc7441e6e9d37f5c9bba (patch)
tree3deff42e5df9db82d26eee20527ef01d85e7fc2e /drivers/mmc
parent5fc63dfba8a016caf832572aeaa90abef82f0ba0 (diff)
imxmmc: fix crash when no platform data is provided
Don't crash if no platform data is provided. In this case assume that card is present. Signed-off-by: Paulius Zaleckas <paulius.zaleckas@teltonika.lt> Acked-by: Pavel Pisa <pisa@cmp.felk.cvut.cz> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/host/imxmmc.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/mmc/host/imxmmc.c b/drivers/mmc/host/imxmmc.c
index 9cda12fba9aa..f61406da65d2 100644
--- a/drivers/mmc/host/imxmmc.c
+++ b/drivers/mmc/host/imxmmc.c
@@ -905,7 +905,8 @@ static void imxmci_check_status(unsigned long data)
905{ 905{
906 struct imxmci_host *host = (struct imxmci_host *)data; 906 struct imxmci_host *host = (struct imxmci_host *)data;
907 907
908 if( host->pdata->card_present(mmc_dev(host->mmc)) != host->present ) { 908 if (host->pdata && host->pdata->card_present &&
909 host->pdata->card_present(mmc_dev(host->mmc)) != host->present) {
909 host->present ^= 1; 910 host->present ^= 1;
910 dev_info(mmc_dev(host->mmc), "card %s\n", 911 dev_info(mmc_dev(host->mmc), "card %s\n",
911 host->present ? "inserted" : "removed"); 912 host->present ? "inserted" : "removed");
@@ -968,6 +969,8 @@ static int imxmci_probe(struct platform_device *pdev)
968 host->mmc = mmc; 969 host->mmc = mmc;
969 host->dma_allocated = 0; 970 host->dma_allocated = 0;
970 host->pdata = pdev->dev.platform_data; 971 host->pdata = pdev->dev.platform_data;
972 if (!host->pdata)
973 dev_warn(&pdev->dev, "No platform data provided!\n");
971 974
972 spin_lock_init(&host->lock); 975 spin_lock_init(&host->lock);
973 host->res = r; 976 host->res = r;
@@ -1020,7 +1023,11 @@ static int imxmci_probe(struct platform_device *pdev)
1020 if (ret) 1023 if (ret)
1021 goto out; 1024 goto out;
1022 1025
1023 host->present = host->pdata->card_present(mmc_dev(mmc)); 1026 if (host->pdata && host->pdata->card_present)
1027 host->present = host->pdata->card_present(mmc_dev(mmc));
1028 else /* if there is no way to detect assume that card is present */
1029 host->present = 1;
1030
1024 init_timer(&host->timer); 1031 init_timer(&host->timer);
1025 host->timer.data = (unsigned long)host; 1032 host->timer.data = (unsigned long)host;
1026 host->timer.function = imxmci_check_status; 1033 host->timer.function = imxmci_check_status;