mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-16 18:04:48 +00:00
dm: blk: Add 'erase' generic block device commands
Add support for doing 'erase' using the generic block commands framework. Signed-off-by: Varadarajan Narayanan <quic_varada@quicinc.com>
This commit is contained in:
parent
157119d69a
commit
6a5177a58c
1 changed files with 17 additions and 0 deletions
|
@ -107,6 +107,23 @@ int blk_common_cmd(int argc, char *const argv[], enum uclass_id uclass_id,
|
|||
printf("%ld blocks written: %s\n", n,
|
||||
n == cnt ? "OK" : "ERROR");
|
||||
return n == cnt ? CMD_RET_SUCCESS : CMD_RET_FAILURE;
|
||||
} else if (strcmp(argv[1], "erase") == 0) {
|
||||
lbaint_t blk = hextoul(argv[2], NULL);
|
||||
ulong cnt = hextoul(argv[3], NULL);
|
||||
struct blk_desc *desc;
|
||||
ulong n;
|
||||
|
||||
printf("\n%s erase: device %d block # "LBAFU", count %lu ... ",
|
||||
if_name, *cur_devnump, blk, cnt);
|
||||
|
||||
if (blk_get_desc(uclass_id, *cur_devnump, &desc))
|
||||
return CMD_RET_FAILURE;
|
||||
|
||||
n = blk_derase(desc, blk, cnt);
|
||||
|
||||
printf("%ld blocks erased: %s\n", n,
|
||||
n == cnt ? "OK" : "ERROR");
|
||||
return n == cnt ? CMD_RET_SUCCESS : CMD_RET_FAILURE;
|
||||
} else {
|
||||
return CMD_RET_USAGE;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue