]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: blk: Fix allocation of block-device numbering
authorSimon Glass <sjg@chromium.org>
Sun, 1 May 2016 19:52:22 +0000 (13:52 -0600)
committerSimon Glass <sjg@chromium.org>
Tue, 17 May 2016 15:54:43 +0000 (09:54 -0600)
Due to code ordering the block devices are not numbered sequentially. Fix
this.

Signed-off-by: Simon Glass <sjg@chromium.org>
drivers/block/blk-uclass.c

index 6ecbff0e93d4170a4641701e349cfd8b076a91e2..f67f9b9d5524cc7c01d5063ff06cb472a75868c0 100644 (file)
@@ -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;