[RFC PATCH 24/77] dtc: Introduce update_exports_ref()
Herve Codina <[email protected]> Mon, 12 Jan 2026 15:19:14 +0100
| Newsgroups | org.kernel.vger.devicetree-spec,org.kernel.vger.devicetree-compiler,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
In order to have consistent internal data when a export symbol using a local phandle is parsed from a dtb, the reference related to this phandle usage needs to be updated based on the phandle value. This is done for phandles used by properties in update_phandles_ref(). The same operation is needed for export symbols. This is the purpose of update_exports_ref(). Signed-off-by: Herve Codina <[email protected]> --- dtc.c | 1 + dtc.h | 1 + livetree.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/dtc.c b/dtc.c index 030bfa2..e0a0b54 100644 --- a/dtc.c +++ b/dtc.c @@ -336,6 +336,7 @@ int main(int argc, char *argv[]) update_phandles_ref(dti); mark_local_phandles(dti); + update_exports_ref(dti); mark_local_exports(dti); /* diff --git a/dtc.h b/dtc.h index ea073c2..024e172 100644 --- a/dtc.h +++ b/dtc.h @@ -368,6 +368,7 @@ 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 update_exports_ref(struct dt_info *dti); void mark_local_exports(struct dt_info *dti); /* Checks */ diff --git a/livetree.c b/livetree.c index 0e756b8..7cf3ee5 100644 --- a/livetree.c +++ b/livetree.c @@ -1304,6 +1304,36 @@ void mark_local_phandles(struct dt_info *dti) mark_local_phandles_internal(dti, dti->dt); } +static void update_exports_ref_internal(struct dt_info *dti, struct node *node) +{ + struct node *c; + struct symbol *exportsym; + struct node *refnode; + + for_each_symbol(node->exportsymlist, exportsym) { + if (exportsym->ref) + continue; + + if (exportsym->is_local) { + refnode = get_node_by_phandle(dti->dt, exportsym->phandle); + if (!refnode) + die("Node not found for phandle 0x%"PRIx32"\n", exportsym->phandle); + + exportsym->ref = refnode->fullpath; + } else { + die("Found a non local phandle without a reference\n"); + } + } + + for_each_child(node, c) + update_exports_ref_internal(dti, c); +} + +void update_exports_ref(struct dt_info *dti) +{ + update_exports_ref_internal(dti, dti->dt); +} + static void mark_local_exports_internal(struct dt_info *dti, struct node *node) { -- 2.52.0