]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
blk: blkmap: Support mapping to device of any block size
authorBin Meng <bmeng@tinylab.org>
Tue, 26 Sep 2023 08:43:39 +0000 (16:43 +0800)
committerTom Rini <trini@konsulko.com>
Tue, 10 Oct 2023 20:25:48 +0000 (16:25 -0400)
At present if a device to map has a block size other than 512,
the blkmap map process just fails. There is no reason why we
can't just use the block size of the mapped device.

Signed-off-by: Bin Meng <bmeng@tinylab.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
drivers/block/blkmap.c

index f6acfa892768674243b1e4a854c2f72d98ef6703..149a4cac3eaa314dacc9bb367cf4de11532b2e0a 100644 (file)
@@ -171,11 +171,11 @@ int blkmap_map_linear(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt,
 
        bd = dev_get_uclass_plat(bm->blk);
        lbd = dev_get_uclass_plat(lblk);
-       if (lbd->blksz != bd->blksz)
-               /* We could support block size translation, but we
-                * don't yet.
-                */
-               return -EINVAL;
+       if (lbd->blksz != bd->blksz) {
+               /* update to match the mapped device */
+               bd->blksz = lbd->blksz;
+               bd->log2blksz = LOG2(bd->blksz);
+       }
 
        linear = malloc(sizeof(*linear));
        if (!linear)