aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBin Meng2018-10-15 04:21:07 -0500
committerSimon Glass2018-11-14 11:16:27 -0600
commitd0851c8937067ad396f2bdafc46d0326bf3317db (patch)
treeac5d2b7aa32a96f248b61b5559aa3e7fc961e951
parentf26ce03b444ac97448eca0cc58071f5fa8ffc3bd (diff)
downloadu-boot-d0851c8937067ad396f2bdafc46d0326bf3317db.tar.gz
u-boot-d0851c8937067ad396f2bdafc46d0326bf3317db.tar.xz
u-boot-d0851c8937067ad396f2bdafc46d0326bf3317db.zip
blk: Call part_init() in the post_probe() method
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>
-rw-r--r--cmd/sata.c9
-rw-r--r--common/usb_storage.c4
-rw-r--r--drivers/block/blk-uclass.c12
-rw-r--r--drivers/block/ide.c2
-rw-r--r--drivers/block/sandbox.c2
-rw-r--r--drivers/mmc/mmc.c3
-rw-r--r--drivers/nvme/nvme.c1
-rw-r--r--drivers/scsi/scsi.c1
-rw-r--r--lib/efi_driver/efi_block_device.c2
9 files changed, 14 insertions, 22 deletions
diff --git a/cmd/sata.c b/cmd/sata.c
index 4f0c6e0137..6d62ba8f74 100644
--- a/cmd/sata.c
+++ b/cmd/sata.c
@@ -51,7 +51,6 @@ int sata_probe(int devnum)
51{ 51{
52#ifdef CONFIG_AHCI 52#ifdef CONFIG_AHCI
53 struct udevice *dev; 53 struct udevice *dev;
54 struct udevice *blk;
55 int rc; 54 int rc;
56 55
57 rc = uclass_get_device(UCLASS_AHCI, devnum, &dev); 56 rc = uclass_get_device(UCLASS_AHCI, devnum, &dev);
@@ -67,14 +66,6 @@ int sata_probe(int devnum)
67 return CMD_RET_FAILURE; 66 return CMD_RET_FAILURE;
68 } 67 }
69 68
70 rc = blk_get_from_parent(dev, &blk);
71 if (!rc) {
72 struct blk_desc *desc = dev_get_uclass_platdata(blk);
73
74 if (desc->lba > 0 && desc->blksz > 0)
75 part_init(desc);
76 }
77
78 return 0; 69 return 0;
79#else 70#else
80 return sata_initialize() < 0 ? CMD_RET_FAILURE : CMD_RET_SUCCESS; 71 return sata_initialize() < 0 ? CMD_RET_FAILURE : CMD_RET_SUCCESS;
diff --git a/common/usb_storage.c b/common/usb_storage.c
index d92ebb6eb1..560d60538b 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -226,9 +226,7 @@ static int usb_stor_probe_device(struct usb_device *udev)
226 blkdev->lun = lun; 226 blkdev->lun = lun;
227 227
228 ret = usb_stor_get_info(udev, data, blkdev); 228 ret = usb_stor_get_info(udev, data, blkdev);
229 if (ret == 1) 229 if (ret == 1) {
230 ret = blk_prepare_device(dev);
231 if (!ret) {
232 usb_max_devs++; 230 usb_max_devs++;
233 debug("%s: Found device %p\n", __func__, udev); 231 debug("%s: Found device %p\n", __func__, udev);
234 } else { 232 } else {
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index facf52711c..95e7b540a5 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -644,8 +644,20 @@ int blk_unbind_all(int if_type)
644 return 0; 644 return 0;
645} 645}
646 646
647static int blk_post_probe(struct udevice *dev)
648{
649#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBDISK_SUPPORT)
650 struct blk_desc *desc = dev_get_uclass_platdata(dev);
651
652 part_init(desc);
653#endif
654
655 return 0;
656}
657
647UCLASS_DRIVER(blk) = { 658UCLASS_DRIVER(blk) = {
648 .id = UCLASS_BLK, 659 .id = UCLASS_BLK,
649 .name = "blk", 660 .name = "blk",
661 .post_probe = blk_post_probe,
650 .per_device_platdata_auto_alloc_size = sizeof(struct blk_desc), 662 .per_device_platdata_auto_alloc_size = sizeof(struct blk_desc),
651}; 663};
diff --git a/drivers/block/ide.c b/drivers/block/ide.c
index 38adb6a241..4b8a4eac17 100644
--- a/drivers/block/ide.c
+++ b/drivers/block/ide.c
@@ -1169,8 +1169,6 @@ static int ide_blk_probe(struct udevice *udev)
1169 BLK_REV_SIZE); 1169 BLK_REV_SIZE);
1170 desc->revision[BLK_REV_SIZE] = '\0'; 1170 desc->revision[BLK_REV_SIZE] = '\0';
1171 1171
1172 part_init(desc);
1173
1174 return 0; 1172 return 0;
1175} 1173}
1176 1174
diff --git a/drivers/block/sandbox.c b/drivers/block/sandbox.c
index 576d049df7..d3b1aaaba3 100644
--- a/drivers/block/sandbox.c
+++ b/drivers/block/sandbox.c
@@ -142,7 +142,7 @@ int host_dev_bind(int devnum, char *filename)
142 goto err_file; 142 goto err_file;
143 } 143 }
144 144
145 return blk_prepare_device(dev); 145 return 0;
146err_file: 146err_file:
147 os_close(fd); 147 os_close(fd);
148err: 148err:
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 585951cd78..d6b9cdc992 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -2444,9 +2444,6 @@ static int mmc_startup(struct mmc *mmc)
2444 bdesc->product[0] = 0; 2444 bdesc->product[0] = 0;
2445 bdesc->revision[0] = 0; 2445 bdesc->revision[0] = 0;
2446#endif 2446#endif
2447#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBDISK_SUPPORT)
2448 part_init(bdesc);
2449#endif
2450 2447
2451 return 0; 2448 return 0;
2452} 2449}
diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c
index eb6fdeda50..1ee0a0aefb 100644
--- a/drivers/nvme/nvme.c
+++ b/drivers/nvme/nvme.c
@@ -664,7 +664,6 @@ static int nvme_blk_probe(struct udevice *udev)
664 sprintf(desc->vendor, "0x%.4x", pplat->vendor); 664 sprintf(desc->vendor, "0x%.4x", pplat->vendor);
665 memcpy(desc->product, ndev->serial, sizeof(ndev->serial)); 665 memcpy(desc->product, ndev->serial, sizeof(ndev->serial));
666 memcpy(desc->revision, ndev->firmware_rev, sizeof(ndev->firmware_rev)); 666 memcpy(desc->revision, ndev->firmware_rev, sizeof(ndev->firmware_rev));
667 part_init(desc);
668 667
669 return 0; 668 return 0;
670} 669}
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index bc6ac8cd32..df47e2fc78 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -592,7 +592,6 @@ static int do_scsi_scan_one(struct udevice *dev, int id, int lun, bool verbose)
592 memcpy(&bdesc->vendor, &bd.vendor, sizeof(bd.vendor)); 592 memcpy(&bdesc->vendor, &bd.vendor, sizeof(bd.vendor));
593 memcpy(&bdesc->product, &bd.product, sizeof(bd.product)); 593 memcpy(&bdesc->product, &bd.product, sizeof(bd.product));
594 memcpy(&bdesc->revision, &bd.revision, sizeof(bd.revision)); 594 memcpy(&bdesc->revision, &bd.revision, sizeof(bd.revision));
595 part_init(bdesc);
596 595
597 if (verbose) { 596 if (verbose) {
598 printf(" Device %d: ", 0); 597 printf(" Device %d: ", 0);
diff --git a/lib/efi_driver/efi_block_device.c b/lib/efi_driver/efi_block_device.c
index 7b71b4dd2e..3f147cf608 100644
--- a/lib/efi_driver/efi_block_device.c
+++ b/lib/efi_driver/efi_block_device.c
@@ -173,8 +173,6 @@ static int efi_bl_bind(efi_handle_t handle, void *interface)
173 return ret; 173 return ret;
174 EFI_PRINT("%s: block device '%s' created\n", __func__, bdev->name); 174 EFI_PRINT("%s: block device '%s' created\n", __func__, bdev->name);
175 175
176 ret = blk_prepare_device(bdev);
177
178 /* Create handles for the partions of the block device */ 176 /* Create handles for the partions of the block device */
179 disks = efi_bl_bind_partitions(handle, bdev); 177 disks = efi_bl_bind_partitions(handle, bdev);
180 EFI_PRINT("Found %d partitions\n", disks); 178 EFI_PRINT("Found %d partitions\n", disks);