1 // SPDX-License-Identifier: GPL-2.0+
5 * Copyright 2023 Google LLC
13 #include <dm/ofnode.h>
14 #include <linux/sizes.h>
18 static int do_cedit_load(struct cmd_tbl *cmdtp, int flag, int argc,
32 ret = fs_load_alloc(argv[1], argv[2], argv[3], SZ_1M, 0, &buf, &size);
34 printf("File not found\n");
35 return CMD_RET_FAILURE;
38 tree = oftree_from_fdt(buf);
39 if (!oftree_valid(tree)) {
40 printf("Cannot create oftree\n");
41 return CMD_RET_FAILURE;
44 ret = expo_build(oftree_root(tree), &exp);
47 printf("Failed to build expo: %dE\n", ret);
48 return CMD_RET_FAILURE;
56 static int do_cedit_run(struct cmd_tbl *cmdtp, int flag, int argc,
63 printf("No expo loaded\n");
64 return CMD_RET_FAILURE;
67 node = ofnode_path("/cedit-theme");
68 if (ofnode_valid(node)) {
69 ret = expo_apply_theme(cur_exp, node);
71 return CMD_RET_FAILURE;
73 log_warning("No theme found\n");
75 ret = cedit_run(cur_exp);
77 log_err("Failed (err=%dE)\n", ret);
78 return CMD_RET_FAILURE;
84 #ifdef CONFIG_SYS_LONGHELP
85 static char cedit_help_text[] =
86 "load <interface> <dev[:part]> <filename> - load config editor\n"
87 "cedit run - run config editor";
88 #endif /* CONFIG_SYS_LONGHELP */
90 U_BOOT_CMD_WITH_SUBCMDS(cedit, "Configuration editor", cedit_help_text,
91 U_BOOT_SUBCMD_MKENT(load, 5, 1, do_cedit_load),
92 U_BOOT_SUBCMD_MKENT(run, 1, 1, do_cedit_run),