mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] commands: of_dump: implement -p for printing properties only
Date: Mon, 31 May 2021 09:01:03 +0200
Message-ID: <20210531070103.GB5211@pengutronix.de> (raw)
In-Reply-To: <20210527124406.22121-1-a.fatoum@pengutronix.de>

On Thu, May 27, 2021 at 02:44:06PM +0200, Ahmad Fatoum wrote:
> 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>
> ---
>  commands/of_dump.c | 14 ++++++++++----
>  drivers/of/base.c  |  8 ++++++++
>  include/of.h       |  1 +
>  3 files changed, 19 insertions(+), 4 deletions(-)

Nice. This annoyed me as well sometimes. Applied, thanks

Sascha

> 
> diff --git a/commands/of_dump.c b/commands/of_dump.c
> index 6792af3afc31..2089c07ef79b 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)
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 6fe02649ee53..e103eed90af1 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -2002,6 +2002,14 @@ static void __of_print_property(struct property *p, int indent)
>  	printf(";\n");
>  }
>  
> +void of_print_properties(struct device_node *node)
> +{
> +	struct property *prop;
> +
> +	list_for_each_entry(prop, &node->properties, list)
> +		__of_print_property(prop, 0);
> +}
> +
>  static int __of_print_parents(struct device_node *node)
>  {
>  	int indent, i;
> diff --git a/include/of.h b/include/of.h
> index 645f429bdeed..55e6bff8689e 100644
> --- a/include/of.h
> +++ b/include/of.h
> @@ -105,6 +105,7 @@ void of_print_property(const void *data, int len);
>  void of_print_cmdline(struct device_node *root);
>  
>  void of_print_nodes(struct device_node *node, int indent);
> +void of_print_properties(struct device_node *node);
>  void of_diff(struct device_node *a, struct device_node *b, int indent);
>  int of_probe(void);
>  int of_parse_dtb(struct fdt_header *fdt);
> -- 
> 2.29.2
> 
> 
> _______________________________________________
> 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


      reply	other threads:[~2021-05-31  7:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-27 12:44 Ahmad Fatoum
2021-05-31  7:01 ` Sascha Hauer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210531070103.GB5211@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

mail archive of the barebox mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://lore.barebox.org/barebox/0 barebox/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 barebox barebox/ https://lore.barebox.org/barebox \
		barebox@lists.infradead.org barebox@lists.infradead.org
	public-inbox-index barebox

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git