From d0851c8937067ad396f2bdafc46d0326bf3317db Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Mon, 15 Oct 2018 02:21:07 -0700 Subject: 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 Reviewed-by: Simon Glass --- drivers/block/blk-uclass.c | 12 ++++++++++++ drivers/block/ide.c | 2 -- drivers/block/sandbox.c | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) (limited to 'drivers/block') 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: -- cgit