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>

authored by

Paulius Zaleckas and committed by
Pierre Ossman
c5d5e9c4 5fc63dfb

+9 -2
+9 -2
drivers/mmc/host/imxmmc.c
··· 905 905 { 906 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 910 host->present ^= 1; 910 911 dev_info(mmc_dev(host->mmc), "card %s\n", 911 912 host->present ? "inserted" : "removed"); ··· 969 968 host->mmc = mmc; 970 969 host->dma_allocated = 0; 971 970 host->pdata = pdev->dev.platform_data; 971 + if (!host->pdata) 972 + dev_warn(&pdev->dev, "No platform data provided!\n"); 972 973 973 974 spin_lock_init(&host->lock); 974 975 host->res = r; ··· 1023 1020 if (ret) 1024 1021 goto out; 1025 1022 1026 - host->present = host->pdata->card_present(mmc_dev(mmc)); 1023 + if (host->pdata && host->pdata->card_present) 1024 + host->present = host->pdata->card_present(mmc_dev(mmc)); 1025 + else /* if there is no way to detect assume that card is present */ 1026 + host->present = 1; 1027 + 1027 1028 init_timer(&host->timer); 1028 1029 host->timer.data = (unsigned long)host; 1029 1030 host->timer.function = imxmci_check_status;