[RFC 09/22] dm: blk: add a device-probe hook for scanning disk partitions

AKASHI Takahiro
2021-10-01T05:06:15Z

Now that all the block device drivers have enable a probe hook, we will
call blk_create_partitions() to enumerate all the partitions and create
associated udevices when a block device is detected.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
---
drivers/block/blk-uclass.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)

diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index dd7f3c0fe31e..6ba11a8fa7f7 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -741,11 +741,25 @@ static int blk_post_probe(struct udevice *dev)
struct blk_desc *desc = dev_get_uclass_plat(dev);

part_init(desc);
+
+ if (desc->part_type != PART_TYPE_UNKNOWN &&
+ blk_create_partitions(dev))
+ debug("*** creating partitions failed\n");
}

return 0;
}

+static int blk_part_post_probe(struct udevice *dev)
+{
+ /*
+ * TODO:
+ * If we call blk_creat_partitions() here, it would allow for
+ * "partitions in a partition".
+ */
+ return 0;
+}
+
UCLASS_DRIVER(blk) = {
.id = UCLASS_BLK,
.name = "blk",
@@ -821,6 +835,7 @@ U_BOOT_DRIVER(blk_partition) = {

UCLASS_DRIVER(partition) = {
.id = UCLASS_PARTITION,
+ .post_probe = blk_part_post_probe,
.per_device_plat_auto = sizeof(struct disk_part),
.name = "partition",
};
--
2.33.0