]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
blk: Call part_init() in the post_probe() method
authorBin Meng <bmeng.cn@gmail.com>
Mon, 15 Oct 2018 09:21:07 +0000 (02:21 -0700)
committerSimon Glass <sjg@chromium.org>
Wed, 14 Nov 2018 17:16:27 +0000 (09:16 -0800)
part_init() is currently called in every DM BLK driver, either
in its bind() or probe() method. However we can use the BLK
uclass driver's post_probe() method to do it automatically.

Update all DM BLK drivers to adopt this change.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
cmd/sata.c
common/usb_storage.c
drivers/block/blk-uclass.c
drivers/block/ide.c
drivers/block/sandbox.c
drivers/mmc/mmc.c
drivers/nvme/nvme.c
drivers/scsi/scsi.c
lib/efi_driver/efi_block_device.c

index 4f0c6e0137162e1990b115436be2e016a667edbd..6d62ba8f74aaceb9702d9db361e68966b89b304a 100644 (file)
@@ -51,7 +51,6 @@ int sata_probe(int devnum)
 {
 #ifdef CONFIG_AHCI
        struct udevice *dev;
-       struct udevice *blk;
        int rc;
 
        rc = uclass_get_device(UCLASS_AHCI, devnum, &dev);
@@ -67,14 +66,6 @@ int sata_probe(int devnum)
                return CMD_RET_FAILURE;
        }
 
-       rc = blk_get_from_parent(dev, &blk);
-       if (!rc) {
-               struct blk_desc *desc = dev_get_uclass_platdata(blk);
-
-               if (desc->lba > 0 && desc->blksz > 0)
-                       part_init(desc);
-       }
-
        return 0;
 #else
        return sata_initialize() < 0 ? CMD_RET_FAILURE : CMD_RET_SUCCESS;
index d92ebb6eb19043fba3851885ea8dfc94652c50c8..560d60538b645b62f41e1df70f7218af3866ec50 100644 (file)
@@ -226,9 +226,7 @@ static int usb_stor_probe_device(struct usb_device *udev)
                blkdev->lun = lun;
 
                ret = usb_stor_get_info(udev, data, blkdev);
-               if (ret == 1)
-                       ret = blk_prepare_device(dev);
-               if (!ret) {
+               if (ret == 1) {
                        usb_max_devs++;
                        debug("%s: Found device %p\n", __func__, udev);
                } else {
index facf52711ccfd735171ba7c0235aa275ad089af1..95e7b540a58758531fe06449e627e9f2cf3c3a67 100644 (file)
@@ -644,8 +644,20 @@ int blk_unbind_all(int if_type)
        return 0;
 }
 
+static int blk_post_probe(struct udevice *dev)
+{
+#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBDISK_SUPPORT)
+       struct blk_desc *desc = dev_get_uclass_platdata(dev);
+
+       part_init(desc);
+#endif
+
+       return 0;
+}
+
 UCLASS_DRIVER(blk) = {
        .id             = UCLASS_BLK,
        .name           = "blk",
+       .post_probe     = blk_post_probe,
        .per_device_platdata_auto_alloc_size = sizeof(struct blk_desc),
 };
index 38adb6a2417892238a8e78ae9dd476c024fd68b3..4b8a4eac176cfa122a9287644e2f8d481821c51a 100644 (file)
@@ -1169,8 +1169,6 @@ static int ide_blk_probe(struct udevice *udev)
                BLK_REV_SIZE);
        desc->revision[BLK_REV_SIZE] = '\0';
 
-       part_init(desc);
-
        return 0;
 }
 
index 576d049df7774c1ddd76a6312c8a548af45a553c..d3b1aaaba36d77921ad306f39e9606821ed8b92e 100644 (file)
@@ -142,7 +142,7 @@ int host_dev_bind(int devnum, char *filename)
                goto err_file;
        }
 
-       return blk_prepare_device(dev);
+       return 0;
 err_file:
        os_close(fd);
 err:
index 585951cd78e917045c2d0ecb113cba06698817ff..d6b9cdc99229d8bfe0c8be3adfd6e5209a11601c 100644 (file)
@@ -2444,9 +2444,6 @@ static int mmc_startup(struct mmc *mmc)
        bdesc->product[0] = 0;
        bdesc->revision[0] = 0;
 #endif
-#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBDISK_SUPPORT)
-       part_init(bdesc);
-#endif
 
        return 0;
 }
index eb6fdeda5015b33ce7d52b5b62201d2d3d0dd729..1ee0a0aefb14e350d878e2237a29962af57d6834 100644 (file)
@@ -664,7 +664,6 @@ static int nvme_blk_probe(struct udevice *udev)
        sprintf(desc->vendor, "0x%.4x", pplat->vendor);
        memcpy(desc->product, ndev->serial, sizeof(ndev->serial));
        memcpy(desc->revision, ndev->firmware_rev, sizeof(ndev->firmware_rev));
-       part_init(desc);
 
        return 0;
 }
index bc6ac8cd327a63ff81dba132a2b4a8618ef230fd..df47e2fc78bdc5c611e11a2c952481fda0185ed9 100644 (file)
@@ -592,7 +592,6 @@ static int do_scsi_scan_one(struct udevice *dev, int id, int lun, bool verbose)
        memcpy(&bdesc->vendor, &bd.vendor, sizeof(bd.vendor));
        memcpy(&bdesc->product, &bd.product, sizeof(bd.product));
        memcpy(&bdesc->revision, &bd.revision,  sizeof(bd.revision));
-       part_init(bdesc);
 
        if (verbose) {
                printf("  Device %d: ", 0);
index 7b71b4dd2e2c50d21cc8ab624123a61124c5dad5..3f147cf6087948db2951e40ee8c9592ef5aa10f4 100644 (file)
@@ -173,8 +173,6 @@ static int efi_bl_bind(efi_handle_t handle, void *interface)
                return ret;
        EFI_PRINT("%s: block device '%s' created\n", __func__, bdev->name);
 
-       ret = blk_prepare_device(bdev);
-
        /* Create handles for the partions of the block device */
        disks = efi_bl_bind_partitions(handle, bdev);
        EFI_PRINT("Found %d partitions\n", disks);