Skip to content
This repository has been archived by the owner on Apr 25, 2020. It is now read-only.

added block command which returns the block size #2

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions cmd/part.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
enum cmd_part_info {
CMD_PART_INFO_START = 0,
CMD_PART_INFO_SIZE,
CMD_PART_INFO_BLOCK,
CMD_PART_INFO_NUMBER
};

Expand Down Expand Up @@ -151,6 +152,9 @@ static int do_part_info(int argc, char * const argv[], enum cmd_part_info param)
case CMD_PART_INFO_SIZE:
snprintf(buf, sizeof(buf), LBAF, info.size);
break;
case CMD_PART_INFO_BLOCK:
snprintf(buf, sizeof(buf), LBAF, info.blksz);
break;
case CMD_PART_INFO_NUMBER:
snprintf(buf, sizeof(buf), "0x%x", part);
break;
Expand All @@ -177,6 +181,11 @@ static int do_part_size(int argc, char * const argv[])
return do_part_info(argc, argv, CMD_PART_INFO_SIZE);
}

static int do_part_block(int argc, char * const argv[])
{
return do_part_info(argc, argv, CMD_PART_INFO_BLOCK);
}

static int do_part_number(int argc, char * const argv[])
{
return do_part_info(argc, argv, CMD_PART_INFO_NUMBER);
Expand All @@ -195,6 +204,8 @@ static int do_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
return do_part_start(argc - 2, argv + 2);
else if (!strcmp(argv[1], "size"))
return do_part_size(argc - 2, argv + 2);
else if (!strcmp(argv[1], "block"))
return do_part_block(argc - 2, argv + 2);
else if (!strcmp(argv[1], "number"))
return do_part_number(argc - 2, argv + 2);

Expand All @@ -219,6 +230,9 @@ U_BOOT_CMD(
"part size <interface> <dev> <part> <varname>\n"
" - set environment variable to the size of the partition (in blocks)\n"
" part can be either partition number or partition name\n"
"part block <interface> <dev> <part> <varname>\n"
" - set environment variable to the size of the partition block\n"
" part can be either partition number or partition name\n"
"part number <interface> <dev> <part> <varname>\n"
" - set environment variable to the partition number using the partition name\n"
" part must be specified as partition name"
Expand Down