Re: [RFC PATCH 23/77] dtc: Introduce mark_local_exports()

David Gibson <[email protected]> Thu, 15 Jan 2026 17:01:51 +1100
Newsgroups org.kernel.vger.devicetree-spec,org.kernel.vger.devicetree-compiler,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-kernel
Message-ID <aWiCz7yZyAvJwPNU@zatzit>
On Mon, Jan 12, 2026 at 03:19:13PM +0100, Herve Codina wrote:
> In order to have correct tags set in dtb, an export symbol has to
> be identified as a "local" export symbol when it references a local
> node.
> 
> This is done for phandles used by properties in mark_local_phandles().
> 
> The same operation is needed for export symbols. This is the purpose of
> mark_local_exports().

Again, I don't like caching this information.  Can you determine this
just at the time you specifically use it?

> 
> Signed-off-by: Herve Codina <[email protected]>
> ---
>  dtc.c      |  2 ++
>  dtc.h      |  2 ++
>  livetree.c | 23 +++++++++++++++++++++++
>  3 files changed, 27 insertions(+)
> 
> diff --git a/dtc.c b/dtc.c
> index fe8e8e4..030bfa2 100644
> --- a/dtc.c
> +++ b/dtc.c
> @@ -336,6 +336,8 @@ int main(int argc, char *argv[])
>  	update_phandles_ref(dti);
>  	mark_local_phandles(dti);
>  
> +	mark_local_exports(dti);
> +
>  	/*
>  	 * With FDT_REF_PHANDLE added in dtbs, we need to identified
>  	 * if some unresolved phandle references are allowed in the dtb
> diff --git a/dtc.h b/dtc.h
> index 0bf5ba5..ea073c2 100644
> --- a/dtc.h
> +++ b/dtc.h
> @@ -368,6 +368,8 @@ void generate_local_fixups_tree(struct dt_info *dti, const char *name);
>  void update_phandles_ref(struct dt_info *dti);
>  void mark_local_phandles(struct dt_info *dti);
>  
> +void mark_local_exports(struct dt_info *dti);
> +
>  /* Checks */
>  
>  void parse_checks_option(bool warn, bool error, const char *arg);
> diff --git a/livetree.c b/livetree.c
> index 4458437..0e756b8 100644
> --- a/livetree.c
> +++ b/livetree.c
> @@ -1303,3 +1303,26 @@ void mark_local_phandles(struct dt_info *dti)
>  {
>  	mark_local_phandles_internal(dti, dti->dt);
>  }
> +
> +static void mark_local_exports_internal(struct dt_info *dti,
> +					struct node *node)
> +{
> +	struct node *c;
> +	struct symbol *exportsym;
> +	struct node *refnode;
> +
> +	for_each_symbol(node->exportsymlist, exportsym) {
> +		refnode = get_node_by_ref(dti->dt, exportsym->ref);
> +		if (refnode)
> +			exportsym->is_local = true;
> +	}
> +
> +	for_each_child(node, c)
> +		mark_local_exports_internal(dti, c);
> +}
> +
> +void mark_local_exports(struct dt_info *dti)
> +{
> +	mark_local_exports_internal(dti, dti->dt);
> +
> +}
> -- 
> 2.52.0
> 
> 

-- 
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
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmlogs4ACgkQzQJF27ox
2Ge3cw/7BWqeTby3qpFeRWudt/kMXwyPjsntxT8XIrH+hogk5z4IqWNCtEKN6vnR
QCwb28M40qIntLxxDafH4U2C8rgdXuOQMudLdv/9lTpGsAIco1k9OQ+j2ARbHoMY
ugigo2jNUENWvnhUs5/vvZsNVHYCWOHzwSSlKWgyDLbzJuBq8s9vNMZSLj6E+ZCc
cJ/EjP/2jiNibFhH9Lf7u3hMi5jaiSJVwEt8HfrYMhSct7GUsizGyShOK1DNre2U
vPNnCDNufjXBRgDOBnbGngmlxlxGdHSmT1xbpX7SoPtEjbUMm5N8WB8SUdoptfKI
lu6GiX6t3e7D8Br6HoN5kFVwlITYl0bXy6vIMLC+OI8uZoBP9epttn1suDbSq+Fq
FCke4Q8vQD6YmQAKjnAAXchRSbYFUiuPUPhW8iFeJk4nFuTIIGX5ylmWn3OLgg1d
QNEShKgB1pBHsy17onuVbYdKcIZld4/wHl9whzXzLSOnFHHbnp/ctW4SKdcSY6xV
AgGS3jKmm5G+TQPq5OLe28MDbHCsPRs66Cl+NqGlr42R7toCvBcApMOQFG0yNcyr
AObvbAF3z79Uik+v17HwbSN66Q4AJlXE9pKXCZ2wKAn9Za4GGZkh6mjv2e00j/oN
es/n5DEXr1Pxt39myjULQxIFdTIxSzyQARt9W5EAj3JZNWg0L0w=
=758D
-----END PGP SIGNATURE-----