From: Igor Opaniuk <igor.opaniuk@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v4 1/2] cmd: part: Add 'number' sub-command
Date: Fri, 14 Jun 2019 16:04:53 +0300 [thread overview]
Message-ID: <20190614130454.26797-2-igor.opaniuk@gmail.com> (raw)
In-Reply-To: <20190614130454.26797-1-igor.opaniuk@gmail.com>
From: Ruslan Trofymenko <ruslan.trofymenko@linaro.org>
This sub-command serves for getting the partition index from
partition name. Also it can be used to test the existence of specified
partition.
Signed-off-by: Ruslan Trofymenko <ruslan.trofymenko@linaro.org>
Signed-off-by: Igor Opaniuk <igor.opaniuk@gmail.com>
Reviewed-by: Alistair Strachan <astrachan@google.com>
Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
Changes in v4: None
Changes in v3: None
Changes in v2: None
cmd/part.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/cmd/part.c b/cmd/part.c
index bfb6488b0f..653e13ced1 100644
--- a/cmd/part.c
+++ b/cmd/part.c
@@ -24,6 +24,7 @@
enum cmd_part_info {
CMD_PART_INFO_START = 0,
CMD_PART_INFO_SIZE,
+ CMD_PART_INFO_NUMBER
};
static int do_part_uuid(int argc, char * const argv[])
@@ -149,6 +150,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_NUMBER:
+ snprintf(buf, sizeof(buf), "%d", part);
+ break;
default:
printf("** Unknown cmd_part_info value: %d\n", param);
return 1;
@@ -172,6 +176,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_number(int argc, char * const argv[])
+{
+ return do_part_info(argc, argv, CMD_PART_INFO_NUMBER);
+}
+
static int do_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
if (argc < 2)
@@ -185,6 +194,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], "number"))
+ return do_part_number(argc - 2, argv + 2);
return CMD_RET_USAGE;
}
@@ -206,5 +217,8 @@ U_BOOT_CMD(
" part can be either partition number or partition name\n"
"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"
+ " 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"
);
--
2.17.1
next prev parent reply other threads:[~2019-06-14 13:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-14 13:04 [U-Boot] [PATCH v4 0/2] Extend 'part' cmd and C API to get part info Igor Opaniuk
2019-06-14 13:04 ` Igor Opaniuk [this message]
2019-06-14 13:26 ` [U-Boot] [PATCH v4 1/2] cmd: part: Add 'number' sub-command Roman Stratiienko
2019-06-14 13:52 ` Igor Opaniuk
2019-06-14 13:56 ` Eugeniu Rosca
2019-06-14 13:04 ` [U-Boot] [PATCH v4 2/2] disk: part: Extend API to get partition info Igor Opaniuk
2019-06-14 13:56 ` [U-Boot] [PATCH v4 0/2] Extend 'part' cmd and C API to get part info Igor Opaniuk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190614130454.26797-2-igor.opaniuk@gmail.com \
--to=igor.opaniuk@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox