[PATCH] fixup! of: add function to read a file as unflattened device tree

Sascha Hauer sha at pengutronix.de
Mon May 22 04:29:58 PDT 2023


On Fri, May 19, 2023 at 09:19:39AM +0200, Ahmad Fatoum wrote:
> of: tidy up of_read_file a bit
> 
>  - change a single instance of space indentation to tabs
>  - use %m instead of unwieldy strerror(errno)
>  - add documentation
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
> ---
>  drivers/of/base.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 918d5e0c5348..5da188115547 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -2893,6 +2893,12 @@ int of_device_disable_by_alias(const char *alias)
>  	return of_device_disable(node);
>  }
>  
> +/**
> + * of_read_file - unflatten oftree file
> + * @filename - path to file to unflatten its contents
> + *
> + * Returns the root node of the tree or an error pointer on error.
> + */
>  struct device_node *of_read_file(const char *filename)
>  {
>  	void *fdt;
> @@ -2901,8 +2907,7 @@ struct device_node *of_read_file(const char *filename)
>  
>  	fdt = read_file(filename, &size);
>  	if (!fdt) {
> -		pr_err("unable to read %s: %s\n", filename,
> -			strerror(errno));
> +		pr_err("unable to read %s: %m\n", filename);
>  		return ERR_PTR(-errno);
>  	}
>  
> @@ -2916,7 +2921,7 @@ struct device_node *of_read_file(const char *filename)
>  out:
>  	free(fdt);
>  
> -       return root;
> +	return root;
>  }
>  
>  /**
> -- 
> 2.39.2
> 
> 
> 

-- 
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