[U-Boot] [PATCH 4/8] dm: blk: Improve block device claiming

sjg at google.com sjg at google.com
Thu May 18 16:01:32 UTC 2017


The intention with block devices is that the device number (devnum field
in its descriptor) matches the alias of its parent device. For example,
with:

	aliases {
		mmc0 = "/sdhci at 700b0600";
		mmc1 = "/sdhci at 700b0400";
	}

we expect that the block devices for mmc0 and mmc1 would have device
numbers of 0 and 1 respectively.

Unfortunately this does not currently always happen. If there is another
MMC device earlier in the driver model data structures its block device
will be created first. It will therefore get device number 0 and mmc0
will therefore miss out. In this case the MMC device will have sequence
number 0 but its block device will not.

To avoid this, allow a device to request a device number and bump any
existing device number that is using it. This all happens during the
binding phase so it is safe to change these numbers around. This allows
device numbers to match the aliases in all circumstances.

Add a test to verify the behaviour.

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

 arch/sandbox/dts/test.dts  | 12 +++++++++++-
 drivers/block/blk-uclass.c | 34 +++++++++++++++++++++++++++++++---
 test/dm/blk.c              | 39 +++++++++++++++++++++++++++++++++++++--
 3 files changed, 79 insertions(+), 6 deletions(-)

Applied to u-boot-dm


More information about the U-Boot mailing list