Re: [PATCH] commands: of_property: Extend command usage on external dtb
From: Sascha Hauer <hidden>
Date: 2021-06-25 08:15:43
Hi, On Thu, Jun 24, 2021 at 05:28:10PM +0200, Yunus Bas wrote:
quoted hunk ↗ jump to hunk
@@ -314,6 +320,9 @@ static int do_of_property(int argc, char *argv[]) case 'f': fixup = 1; break; + case 'e': + dtbfile = optarg; + break; default: return COMMAND_ERROR_USAGE; }@@ -327,8 +336,22 @@ static int do_of_property(int argc, char *argv[]) debug("path: %s propname: %s\n", path, propname); + if ( !(set || delete)) + return COMMAND_ERROR_USAGE; + + if (dtbfile) { + fdt = read_file(dtbfile, &size); + if (!fdt) { + printf("unable to read %s: %s\n", dtbfile, strerror(errno));
We have %m now as a shortcut for "%s", strerror(errno) and you could be the first user ;)
+ if (root && !fixup) {
+ fdt = of_get_fixed_tree(root);
+
+ ret = write_file(dtbfile, fdt, fdt32_to_cpu(fdt->totalsize));
+
+ free(fdt);
}Are you sure you want to save the fixed tree? I would rather expect that the saved tree has only the desired property changed.
quoted hunk ↗ jump to hunk
- return COMMAND_ERROR_USAGE; +out: + + if (root) + of_delete_node(root); + + return ret; } BAREBOX_CMD_HELP_START(of_property)@@ -373,6 +412,7 @@ BAREBOX_CMD_HELP_TEXT("Options:") BAREBOX_CMD_HELP_OPT ("-s", "set property to value") BAREBOX_CMD_HELP_OPT ("-d", "delete property") BAREBOX_CMD_HELP_OPT ("-f", "set/delete as a fixup (defer the action until booting)") +BAREBOX_CMD_HELP_OPT ("-e dtb", "set/delete/fixup from external dtb") BAREBOX_CMD_HELP_TEXT("") BAREBOX_CMD_HELP_TEXT("Valid formats for values:") BAREBOX_CMD_HELP_TEXT("<0x00112233 4 05> - an array of cells. cells not beginning with a digit are")@@ -384,8 +424,8 @@ BAREBOX_CMD_HELP_END BAREBOX_CMD_START(of_property) .cmd = do_of_property, BAREBOX_CMD_DESC("handle device tree properties") - BAREBOX_CMD_OPTS("[-sd] [-f] NODE [PROPERTY] [VALUES]") + BAREBOX_CMD_OPTS("[-sd] [-e] [-f] NODE [PROPERTY] [VALUES]") BAREBOX_CMD_GROUP(CMD_GRP_MISC) - BAREBOX_CMD_COMPLETE(devicetree_complete) + BAREBOX_CMD_COMPLETE(devicetree_file_complete) BAREBOX_CMD_HELP(cmd_of_property_help) BAREBOX_CMD_END-- 2.30.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
-- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox