[PATCH 1/1] cmd/host: allow to retrieve sequence number for label
Heinrich Schuchardt <[email protected]>
| Newsgroups | org.u-boot-project.lists.u-boot |
|---|---|
| Message-ID | <[email protected]> |
When binding a host device the assigned sequence number depends on which host device sequence numbers or unused. Only the label is well known. This sequence number is used in most other commands. For reliable scripting and testing it is therefore necessary to retrieve the sequence number for the label. Add a variant of the `host info` command with a variable name. Write the sequence number for the label to the variable. Signed-off-by: Heinrich Schuchardt <[email protected]> --- cmd/host.c | 5 +++++ doc/usage/cmd/host.rst | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/cmd/host.c b/cmd/host.c index 47a59f5ff20..51f2b1e3f6e 100644 --- a/cmd/host.c +++ b/cmd/host.c @@ -5,6 +5,7 @@ #include <command.h> #include <dm.h> +#include <env.h> #include <fs.h> #include <part.h> #include <sandbox_host.h> @@ -175,6 +176,9 @@ static int do_host_info(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_FAILURE; } + if (argc >= 3) + return env_set_hex(argv[2], dev_seq(dev)); + printf("%3s %12s %6s %-15s %s\n", "dev", "blocks", "blksz", "label", "path"); if (dev) { @@ -264,6 +268,7 @@ U_BOOT_CMD( " -r = mark as removable\n" "host unbind <label> - unbind file from \"host\" device\n" "host info [<label>] - show device binding & info\n" + "host info <label> <var> - write device number to variable\n" "host dev [<label>] - set or retrieve the current host device\n" "host commands use the \"hostfs\" device. The \"host\" device is used\n" "with standard IO commands such as fatls or ext2load" diff --git a/doc/usage/cmd/host.rst b/doc/usage/cmd/host.rst index 672d8f2112b..21ad0c955c2 100644 --- a/doc/usage/cmd/host.rst +++ b/doc/usage/cmd/host.rst @@ -14,6 +14,7 @@ Synopsis host bind [-r] <label> [<filename>] host unbind <label|seq> host info [<label|seq>] + host info <label|seq> <varname> host dev [<label|seq>] Description @@ -61,6 +62,9 @@ host info Provides information about a particular host binding, or all of them. +If a variable name <varname> is provided, the sequence number is written to +the variable and no output is written to the console. + host dev ~~~~~~~~ -- 2.53.0