summaryrefslogtreecommitdiff
path: root/drivers/block
diff options
context:
space:
mode:
authorBin Meng <bmeng.cn@gmail.com>2018-10-15 02:21:07 -0700
committerSimon Glass <sjg@chromium.org>2018-11-14 09:16:27 -0800
commitd0851c8937067ad396f2bdafc46d0326bf3317db (patch)
treeac5d2b7aa32a96f248b61b5559aa3e7fc961e951 /drivers/block
parentf26ce03b444ac97448eca0cc58071f5fa8ffc3bd (diff)
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>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/blk-uclass.c12
-rw-r--r--drivers/block/ide.c2
-rw-r--r--drivers/block/sandbox.c2
3 files changed, 13 insertions, 3 deletions
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)
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),
};
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)
BLK_REV_SIZE);
desc->revision[BLK_REV_SIZE] = '\0';
- part_init(desc);
-
return 0;
}
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)
goto err_file;
}
- return blk_prepare_device(dev);
+ return 0;
err_file:
os_close(fd);
err: