[U-Boot] [PATCH v2 01/24] dm: blk: Fix allocation of block-device numbering

Simon Glass sjg at chromium.org
Sun May 1 21:52:22 CEST 2016


Due to code ordering the block devices are not numbered sequentially. Fix
this.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

Changes in v2: None

 drivers/block/blk-uclass.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index 6ecbff0..f67f9b9 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -439,15 +439,6 @@ int blk_create_device(struct udevice *parent, const char *drv_name,
 	struct udevice *dev;
 	int ret;
 
-	ret = device_bind_driver(parent, drv_name, name, &dev);
-	if (ret)
-		return ret;
-	desc = dev_get_uclass_platdata(dev);
-	desc->if_type = if_type;
-	desc->blksz = blksz;
-	desc->lba = size / blksz;
-	desc->part_type = PART_TYPE_UNKNOWN;
-	desc->bdev = dev;
 	if (devnum == -1) {
 		ret = blk_find_max_devnum(if_type);
 		if (ret == -ENODEV)
@@ -457,6 +448,15 @@ int blk_create_device(struct udevice *parent, const char *drv_name,
 		else
 			devnum = ret + 1;
 	}
+	ret = device_bind_driver(parent, drv_name, name, &dev);
+	if (ret)
+		return ret;
+	desc = dev_get_uclass_platdata(dev);
+	desc->if_type = if_type;
+	desc->blksz = blksz;
+	desc->lba = size / blksz;
+	desc->part_type = PART_TYPE_UNKNOWN;
+	desc->bdev = dev;
 	desc->devnum = devnum;
 	*devp = dev;
 
-- 
2.8.0.rc3.226.g39d4020



More information about the U-Boot mailing list