expo: cedit: Support reading settings from environment vars

Add a command to read cedit settings from environment variables so that
they can be restored as part of the environment.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2023-08-14 16:40:36 -06:00
committed by Tom Rini
parent fc9c0e0771
commit bcf2b7202e
5 changed files with 105 additions and 1 deletions

View File

@@ -156,6 +156,26 @@ static int do_cedit_write_env(struct cmd_tbl *cmdtp, int flag, int argc,
return 0;
}
static int do_cedit_read_env(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
bool verbose;
int ret;
if (check_cur_expo())
return CMD_RET_FAILURE;
verbose = argc > 1 && !strcmp(argv[1], "-v");
ret = cedit_read_settings_env(cur_exp, verbose);
if (ret) {
printf("Failed to read settings from environment: %dE\n", ret);
return CMD_RET_FAILURE;
}
return 0;
}
static int do_cedit_run(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
@@ -187,6 +207,7 @@ static char cedit_help_text[] =
"load <interface> <dev[:part]> <filename> - load config editor\n"
"cedit read_fdt <i/f> <dev[:part]> <filename> - read settings\n"
"cedit write_fdt <i/f> <dev[:part]> <filename> - write settings\n"
"cedit read_env [-v] - read settings from env vars\n"
"cedit write_env [-v] - write settings to env vars\n"
"cedit run - run config editor";
#endif /* CONFIG_SYS_LONGHELP */
@@ -195,6 +216,7 @@ U_BOOT_CMD_WITH_SUBCMDS(cedit, "Configuration editor", cedit_help_text,
U_BOOT_SUBCMD_MKENT(load, 5, 1, do_cedit_load),
U_BOOT_SUBCMD_MKENT(read_fdt, 5, 1, do_cedit_read_fdt),
U_BOOT_SUBCMD_MKENT(write_fdt, 5, 1, do_cedit_write_fdt),
U_BOOT_SUBCMD_MKENT(read_env, 2, 1, do_cedit_read_env),
U_BOOT_SUBCMD_MKENT(write_env, 2, 1, do_cedit_write_env),
U_BOOT_SUBCMD_MKENT(run, 1, 1, do_cedit_run),
);