]> git.baikalelectronics.ru Git - uboot.git/commit
dm: blk: Improve block device claiming
authorSimon Glass <sjg@chromium.org>
Mon, 24 Apr 2017 02:02:07 +0000 (20:02 -0600)
committerSimon Glass <sjg@chromium.org>
Thu, 1 Jun 2017 13:03:05 +0000 (07:03 -0600)
commit0957209cff12e572ef06c01dfb9cb7ef1ce795dd
tree13a6fb91509ee655c8536577e8ec5101c67ac5dd
parent891ca5f11d8572e9780d49f533256c039a0c7b42
dm: blk: Improve block device claiming

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@700b0600";
mmc1 = "/sdhci@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@chromium.org>
arch/sandbox/dts/test.dts
drivers/block/blk-uclass.c
test/dm/blk.c