diff options
author | Bin Meng <bmeng@tinylab.org> | 2023-09-26 16:43:42 +0800 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2023-10-10 16:25:48 -0400 |
commit | 4e345656e7253d655aa8f697350091f3c82c4f0f (patch) | |
tree | 12bf4f2024cef959ff1b0c01e6ce1e82719e0dcd /cmd | |
parent | a9bf25cb93b96502da814f22cd2fbb284272a800 (diff) | |
download | u-boot-4e345656e7253d655aa8f697350091f3c82c4f0f.tar.gz u-boot-4e345656e7253d655aa8f697350091f3c82c4f0f.tar.bz2 u-boot-4e345656e7253d655aa8f697350091f3c82c4f0f.zip |
cmd: blk_common: Stop using hard-coded block size for Sandbox operations
commit 3d2fc7971454 ("cmd: blk: Allow generic read/write operations to work in sandbox")
used the hard-coded block size (512) for accessing the sandbox host
device. Now that we have added support for non-512 block size for both
Sandbox host device and blkmap driver, let's stop using the hard-coded
block size.
Signed-off-by: Bin Meng <bmeng@tinylab.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/blk_common.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/cmd/blk_common.c b/cmd/blk_common.c index ad9b16dc09..02ac92837b 100644 --- a/cmd/blk_common.c +++ b/cmd/blk_common.c @@ -67,15 +67,19 @@ int blk_common_cmd(int argc, char *const argv[], enum uclass_id uclass_id, phys_addr_t paddr = hextoul(argv[2], NULL); lbaint_t blk = hextoul(argv[3], NULL); ulong cnt = hextoul(argv[4], NULL); + struct blk_desc *desc; void *vaddr; ulong n; + int ret; printf("\n%s read: device %d block # "LBAFU", count %lu ... ", if_name, *cur_devnump, blk, cnt); - vaddr = map_sysmem(paddr, 512 * cnt); - n = blk_read_devnum(uclass_id, *cur_devnump, blk, cnt, - vaddr); + ret = blk_get_desc(uclass_id, *cur_devnump, &desc); + if (ret) + return CMD_RET_FAILURE; + vaddr = map_sysmem(paddr, desc->blksz * cnt); + n = blk_dread(desc, blk, cnt, vaddr); unmap_sysmem(vaddr); printf("%ld blocks read: %s\n", n, @@ -85,15 +89,19 @@ int blk_common_cmd(int argc, char *const argv[], enum uclass_id uclass_id, phys_addr_t paddr = hextoul(argv[2], NULL); lbaint_t blk = hextoul(argv[3], NULL); ulong cnt = hextoul(argv[4], NULL); + struct blk_desc *desc; void *vaddr; ulong n; + int ret; printf("\n%s write: device %d block # "LBAFU", count %lu ... ", if_name, *cur_devnump, blk, cnt); - vaddr = map_sysmem(paddr, 512 * cnt); - n = blk_write_devnum(uclass_id, *cur_devnump, blk, cnt, - vaddr); + ret = blk_get_desc(uclass_id, *cur_devnump, &desc); + if (ret) + return CMD_RET_FAILURE; + vaddr = map_sysmem(paddr, desc->blksz * cnt); + n = blk_dwrite(desc, blk, cnt, vaddr); unmap_sysmem(vaddr); printf("%ld blocks written: %s\n", n, |