mmc: sunxi: Set our device drvdata earlier
authorMaxime Ripard <maxime.ripard@bootlin.com>
Thu, 8 Mar 2018 14:52:53 +0000 (15:52 +0100)
committerUlf Hansson <ulf.hansson@linaro.org>
Thu, 15 Mar 2018 13:43:23 +0000 (14:43 +0100)
As soon as the pm_runtime_enable hook is called, our runtime_suspend and
runtime_resume hooks can be called as well. However, we only set the device
drvdata that we will use after we have registered into the MMC core. Move
that earlier so that we don't have a race that could lead to a crash.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/sunxi-mmc.c

index b747d65a7d1562c72cf78d28c2f87c554ccf6b86..20cfb20418f3ef52d8c5858c3c051662898fd448 100644 (file)
@@ -1318,6 +1318,7 @@ static int sunxi_mmc_probe(struct platform_device *pdev)
                dev_err(&pdev->dev, "mmc alloc host failed\n");
                return -ENOMEM;
        }
+       platform_set_drvdata(pdev, mmc);
 
        host = mmc_priv(mmc);
        host->dev = &pdev->dev;
@@ -1384,7 +1385,6 @@ static int sunxi_mmc_probe(struct platform_device *pdev)
                goto error_free_dma;
 
        dev_info(&pdev->dev, "base:0x%p irq:%u\n", host->reg_base, host->irq);
-       platform_set_drvdata(pdev, mmc);
        return 0;
 
 error_free_dma: