[PATCH] of: make of_dump abortable by ctrlc()

Sascha Hauer sha at pengutronix.de
Mon Dec 13 14:16:12 PST 2021


On Thu, Dec 09, 2021 at 11:57:27AM +0100, Ahmad Fatoum wrote:
> Some device trees can be quite long, e.g. because they contain all
> possible pinmux entries. Writing that out over serial can take quite a
> while. Check for ctrlc() between nodes to make these less annoying.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
> ---
>  commands/of_dump.c |  5 ++++-
>  drivers/of/base.c  | 13 ++++++++++---
>  2 files changed, 14 insertions(+), 4 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/commands/of_dump.c b/commands/of_dump.c
> index 5223ba63ad23..6f36b3151458 100644
> --- a/commands/of_dump.c
> +++ b/commands/of_dump.c
> @@ -23,8 +23,11 @@ static void of_print_nodenames(struct device_node *node)
>  
>  	printf("%s\n", node->full_name);
>  
> -	list_for_each_entry(n, &node->children, parent_list)
> +	list_for_each_entry(n, &node->children, parent_list) {
> +		if (ctrlc())
> +			return;
>  		of_print_nodenames(n);
> +	}
>  }
>  
>  static int do_of_dump(int argc, char *argv[])
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 321022f2b391..664a3a411eaf 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -1968,13 +1968,14 @@ int of_property_read_string_helper(const struct device_node *np,
>  	return i <= 0 ? -ENODATA : i;
>  }
>  
> -static void __of_print_nodes(struct device_node *node, int indent, const char *prefix)
> +static int __of_print_nodes(struct device_node *node, int indent, const char *prefix)
>  {
>  	struct device_node *n;
>  	struct property *p;
> +	int ret;
>  
>  	if (!node)
> -		return;
> +		return 0;
>  
>  	if (!prefix)
>  		prefix = "";
> @@ -1990,11 +1991,17 @@ static void __of_print_nodes(struct device_node *node, int indent, const char *p
>  		printf(";\n");
>  	}
>  
> +	if (ctrlc())
> +		return -EINTR;
> +
>  	list_for_each_entry(n, &node->children, parent_list) {
> -		__of_print_nodes(n, indent + 1, prefix);
> +		ret = __of_print_nodes(n, indent + 1, prefix);
> +		if (ret)
> +			return ret;
>  	}
>  
>  	printf("%s%*s};\n", prefix, indent * 8, "");
> +	return 0;
>  }
>  
>  void of_print_nodes(struct device_node *node, int indent)
> -- 
> 2.30.2
> 
> 
> _______________________________________________
> barebox mailing list
> barebox at 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 |



More information about the barebox mailing list