Re: [PATCH 1/2] libfdt: overlay: Allow resolving phandle symbols

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



On Mon, Sep 02, 2024 at 05:47:55PM +0530, Ayush Singh wrote:
> Add ability to resolve symbols pointing to phandles instead of strings.
> 
> Combining this with existing fixups infrastructure allows creating
> symbols in overlays that refer to undefined phandles. This is planned to
> be used for addon board chaining [1].

I don't think this "autodetection" of whether the value is a phandle
or path is a good idea.  Yes, it's probably unlikely to get it wrong
in practice, but sloppy cases like this have a habit of coming back to
bite you later on.  If you want this, I think you need to design a new
way of encoding the new options.

> 
> [1] https://lore.kernel.org/linux-arm-kernel/20240702164403.29067-1-afd@xxxxxx/
> 
> Signed-off-by: Ayush Singh <ayush@xxxxxxxxxxxxxxx>
> ---
>  libfdt/fdt_overlay.c | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/libfdt/fdt_overlay.c b/libfdt/fdt_overlay.c
> index 28b667f..10127be 100644
> --- a/libfdt/fdt_overlay.c
> +++ b/libfdt/fdt_overlay.c
> @@ -395,12 +395,16 @@ static int overlay_fixup_phandle(void *fdt, void *fdto, int symbols_off,
>  	symbol_path = fdt_getprop(fdt, symbols_off, label, &prop_len);
>  	if (!symbol_path)
>  		return prop_len;
> -	
> -	symbol_off = fdt_path_offset(fdt, symbol_path);
> -	if (symbol_off < 0)
> -		return symbol_off;
> -	
> -	phandle = fdt_get_phandle(fdt, symbol_off);
> +
> +	if (prop_len == sizeof(uint32_t) && symbol_path[0] != '/') {
> +		phandle = fdt32_ld((const fdt32_t *)symbol_path);
> +	} else {
> +		symbol_off = fdt_path_offset(fdt, symbol_path);
> +		if (symbol_off < 0)
> +			return symbol_off;
> +		phandle = fdt_get_phandle(fdt, symbol_off);
> +	}
> +
>  	if (!phandle)
>  		return -FDT_ERR_NOTFOUND;
>  
> 

-- 
David Gibson (he or they)	| 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