Re: [PATCH 2/6] libfdt: overlay: Add debug code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Fri, Mar 16, 2018 at 06:37:30PM +0530, Srivatsa Vaddagiri wrote:
> Add fdt_overlay_set_verbose() function in libfdt to enable verbose output from
> overlay function. Also add few debug message to help understand why overlay
> process failed.

libfdt is supposed to be embeddable into a wide variety of
environments, including strange and constrained ones.  Therefore we
try to keep external dependencies to an absolute minimum.  Requiring
stdio for printf() is not ok.

> 
> Signed-off-by: Srivatsa Vaddagiri <vatsa@xxxxxxxxxxxxxx>
> ---
>  fdtoverlay.c         |  1 +
>  libfdt/fdt_overlay.c | 20 +++++++++++++++++++-
>  libfdt/libfdt.h      |  2 ++
>  3 files changed, 22 insertions(+), 1 deletion(-)
> 
> diff --git a/fdtoverlay.c b/fdtoverlay.c
> index 8aed173..308c311 100644
> --- a/fdtoverlay.c
> +++ b/fdtoverlay.c
> @@ -163,6 +163,7 @@ int main(int argc, char *argv[])
>  		usage("missing overlay file(s)");
>  
>  	if (verbose) {
> +		fdt_overlay_set_verbose(1);
>  		printf("input  = %s\n", input_filename);
>  		printf("output = %s\n", output_filename);
>  		for (i = 0; i < argc; i++)
> diff --git a/libfdt/fdt_overlay.c b/libfdt/fdt_overlay.c
> index 64386dd..81b9feb 100644
> --- a/libfdt/fdt_overlay.c
> +++ b/libfdt/fdt_overlay.c
> @@ -56,6 +56,17 @@
>  
>  #include "libfdt_internal.h"
>  
> +int verbose_overlay;
> +
> +#define dprintf(x...)	\
> +	if (verbose_overlay) \
> +		printf(x)
> +
> +void fdt_overlay_set_verbose(int val)
> +{
> +	verbose_overlay = val;
> +}
> +
>  /**
>   * overlay_get_target_phandle - retrieves the target phandle of a fragment
>   * @fdto: pointer to the device tree overlay blob
> @@ -426,8 +437,10 @@ static int overlay_fixup_one_phandle(void *fdt, void *fdto,
>  
>  	symbol_path = fdt_getprop(fdt, symbols_off, label,
>  				  &prop_len);
> -	if (!symbol_path)
> +	if (!symbol_path) {
> +		dprintf("Unable to find symbol %s\n", label);
>  		return prop_len;
> +	}
>  
>  	symbol_off = fdt_path_offset(fdt, symbol_path);
>  	if (symbol_off < 0)
> @@ -869,22 +882,27 @@ int fdt_overlay_apply(void **fdt, void **fdto)
>  	FDT_CHECK_HEADER(*fdt);
>  	FDT_CHECK_HEADER(*fdto);
>  
> +	dprintf("Adjusting local phandles\n");
>  	ret = overlay_adjust_local_phandles(*fdto, delta);
>  	if (ret)
>  		goto err;
>  
> +	dprintf("Updating local references\n");
>  	ret = overlay_update_local_references(*fdto, delta);
>  	if (ret)
>  		goto err;
>  
> +	dprintf("Fixing phandles\n");
>  	ret = overlay_fixup_phandles(*fdt, *fdto);
>  	if (ret)
>  		goto err;
>  
> +	dprintf("Merging blobs\n");
>  	ret = overlay_merge(*fdt, *fdto);
>  	if (ret)
>  		goto err;
>  
> +	dprintf("Updating symbols\n");
>  	ret = overlay_symbol_update(*fdt, *fdto);
>  	if (ret)
>  		goto err;
> diff --git a/libfdt/libfdt.h b/libfdt/libfdt.h
> index 5dd63ef..8e3de74 100644
> --- a/libfdt/libfdt.h
> +++ b/libfdt/libfdt.h
> @@ -1904,4 +1904,6 @@ int fdt_overlay_apply(void **fdt, void **fdto);
>  
>  const char *fdt_strerror(int errval);
>  
> +void fdt_overlay_set_verbose(int verbose);
> +
>  #endif /* LIBFDT_H */

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux