diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2021-05-27 14:44:06 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-05-31 09:00:27 +0200 |
commit | 8a26715aad3d88c3876b3305762a7a549472d969 (patch) | |
tree | dd61e0293ac9198b3cdc75d5b15f2057d6e57c9e /commands | |
parent | 30f96444b68b75dc940fb698df0f4427e437cdf2 (diff) | |
download | barebox-8a26715aad3d88c3876b3305762a7a549472d969.tar.gz barebox-8a26715aad3d88c3876b3305762a7a549472d969.tar.xz |
commands: of_dump: implement -p for printing properties only
Some boards rewrite root node properties like compatible and
serial-number. Checking them can be annoying, because the properties
have usually long scrolled by, by the time the device tree was
completely dumped. Add a -p option to print only properties.
-p -n (print only node names AND only properties) is interpreted
to cancel each other out, so the whole device tree is dumped normally.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20210527124406.22121-1-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r-- | commands/of_dump.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/commands/of_dump.c b/commands/of_dump.c index 6792af3afc..2089c07ef7 100644 --- a/commands/of_dump.c +++ b/commands/of_dump.c @@ -36,9 +36,9 @@ static int do_of_dump(int argc, char *argv[]) char *dtbfile = NULL; size_t size; const char *nodename; - int names_only = 0; + int names_only = 0, properties_only = 0; - while ((opt = getopt(argc, argv, "Ff:n")) > 0) { + while ((opt = getopt(argc, argv, "Ff:np")) > 0) { switch (opt) { case 'f': dtbfile = optarg; @@ -49,6 +49,9 @@ static int do_of_dump(int argc, char *argv[]) case 'n': names_only = 1; break; + case 'p': + properties_only = 1; + break; default: return COMMAND_ERROR_USAGE; } @@ -111,8 +114,10 @@ static int do_of_dump(int argc, char *argv[]) goto out; } - if (names_only) + if (names_only && !properties_only) of_print_nodenames(node); + else if (properties_only && !names_only) + of_print_properties(node); else of_print_nodes(node, 0); @@ -128,12 +133,13 @@ BAREBOX_CMD_HELP_TEXT("Options:") BAREBOX_CMD_HELP_OPT ("-f dtb", "work on dtb instead of internal devicetree") BAREBOX_CMD_HELP_OPT ("-F", "return fixed devicetree") BAREBOX_CMD_HELP_OPT ("-n", "Print node names only, no properties") +BAREBOX_CMD_HELP_OPT ("-p", "Print properties only, no child nodes") BAREBOX_CMD_HELP_END BAREBOX_CMD_START(of_dump) .cmd = do_of_dump, BAREBOX_CMD_DESC("dump devicetree nodes") - BAREBOX_CMD_OPTS("[-fFn] [NODE]") + BAREBOX_CMD_OPTS("[-fFnp] [NODE]") BAREBOX_CMD_GROUP(CMD_GRP_MISC) BAREBOX_CMD_COMPLETE(devicetree_file_complete) BAREBOX_CMD_HELP(cmd_of_dump_help) |