mmc: init mmc block devices on probe
authorFiach Antaw <fiach.antaw@uqconnect.edu.au>
Wed, 25 Jan 2017 09:00:24 +0000 (19:00 +1000)
committerJaehoon Chung <jh80.chung@samsung.com>
Thu, 9 Feb 2017 11:37:06 +0000 (20:37 +0900)
MMC devices accessed exclusively via the driver model were not
being initialized before being exposed as block devices, causing
issues in scenarios where the MMC device is first accessed via the
uclass block interface.

Signed-off-by: Fiach Antaw <fiach.antaw@uqconnect.edu.au>
drivers/mmc/mmc-uclass.c

index de7acb682629a2bd40a3e97f5b03d3d370da60b9..5bb446bcc2a8ff91d42b73071828bdd43ce810ce 100644 (file)
@@ -254,6 +254,17 @@ static int mmc_select_hwpart(struct udevice *bdev, int hwpart)
        return mmc_switch_part(mmc, hwpart);
 }
 
+static int mmc_blk_probe(struct udevice *dev)
+{
+       struct blk_desc *block_dev = dev_get_uclass_platdata(dev);
+       int dev_num = block_dev->devnum;
+       struct mmc *mmc = find_mmc_device(dev_num);
+
+       if (!mmc)
+               return -ENODEV;
+       return mmc_init(mmc);
+}
+
 static const struct blk_ops mmc_blk_ops = {
        .read   = mmc_bread,
 #ifndef CONFIG_SPL_BUILD
@@ -267,6 +278,7 @@ U_BOOT_DRIVER(mmc_blk) = {
        .name           = "mmc_blk",
        .id             = UCLASS_BLK,
        .ops            = &mmc_blk_ops,
+       .probe          = mmc_blk_probe,
 };
 #endif /* CONFIG_BLK */