summaryrefslogtreecommitdiff
path: root/drivers/mmc/host/imxmmc.c
diff options
context:
space:
mode:
authorPaulius Zaleckas <paulius.zaleckas@teltonika.lt>2008-07-09 17:03:20 +0400
committerPierre Ossman <drzeus@drzeus.cx>2008-07-27 03:26:16 +0400
commitc5d5e9c40fc6cabedd5fdc7441e6e9d37f5c9bba (patch)
tree3deff42e5df9db82d26eee20527ef01d85e7fc2e /drivers/mmc/host/imxmmc.c
parent5fc63dfba8a016caf832572aeaa90abef82f0ba0 (diff)
downloadlinux-c5d5e9c40fc6cabedd5fdc7441e6e9d37f5c9bba.tar.xz
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/host/imxmmc.c')
-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)
{
struct imxmci_host *host = (struct imxmci_host *)data;
- if( host->pdata->card_present(mmc_dev(host->mmc)) != host->present ) {
+ if (host->pdata && host->pdata->card_present &&
+ host->pdata->card_present(mmc_dev(host->mmc)) != host->present) {
host->present ^= 1;
dev_info(mmc_dev(host->mmc), "card %s\n",
host->present ? "inserted" : "removed");
@@ -968,6 +969,8 @@ static int imxmci_probe(struct platform_device *pdev)
host->mmc = mmc;
host->dma_allocated = 0;
host->pdata = pdev->dev.platform_data;
+ if (!host->pdata)
+ dev_warn(&pdev->dev, "No platform data provided!\n");
spin_lock_init(&host->lock);
host->res = r;
@@ -1020,7 +1023,11 @@ static int imxmci_probe(struct platform_device *pdev)
if (ret)
goto out;
- host->present = host->pdata->card_present(mmc_dev(mmc));
+ if (host->pdata && host->pdata->card_present)
+ host->present = host->pdata->card_present(mmc_dev(mmc));
+ else /* if there is no way to detect assume that card is present */
+ host->present = 1;
+
init_timer(&host->timer);
host->timer.data = (unsigned long)host;
host->timer.function = imxmci_check_status;