[RFC PATCH v2 48/74] checks: Perform checks for orphan nodes
From: Herve Codina
Date: Wed Aug 26 2026 - 06:10:35 EST
Orphan nodes have been introduced recently.
Those nodes and related trees need to be handled by the check process.
Indeed, in addition to performing checks, phandles are allocated and
referenced nodes are marked 'referenced' during the check process.
Take into account orphan nodes in check process.
Signed-off-by: Herve Codina <herve.codina@xxxxxxxxxxx>
---
checks.c | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/checks.c b/checks.c
index 2b87e212..a0024389 100644
--- a/checks.c
+++ b/checks.c
@@ -155,6 +155,7 @@ static bool is_multiple_of(int multiple, int divisor)
static bool run_check(struct check *c, struct dt_info *dti)
{
struct node *dt = dti->dt;
+ struct node *orphan;
bool error = false;
int i;
@@ -180,6 +181,9 @@ static bool run_check(struct check *c, struct dt_info *dti)
check_nodes_props(c, dti, dt);
+ for_each_orphan(dti->orphanlist, orphan)
+ check_nodes_props(c, dti, orphan);
+
if (c->status == UNCHECKED)
c->status = PASSED;
@@ -313,7 +317,12 @@ ERROR(duplicate_property_names, check_duplicate_property_names, NULL);
static void check_node_name_chars(struct check *c, struct dt_info *dti,
struct node *node)
{
- size_t n = strspn(node->name, c->data);
+ size_t n;
+
+ if ((dti->dtsflags & DTSF_ADDON) && node_is_orphan(dti, node))
+ return; /* Checking name doesn't make sense for an orphan node */
+
+ n = strspn(node->name, c->data);
if (n < strlen(node->name))
FAIL(c, dti, node, "Bad character '%c' in node name",
@@ -324,7 +333,12 @@ ERROR(node_name_chars, check_node_name_chars, NODECHARS);
static void check_node_name_chars_strict(struct check *c, struct dt_info *dti,
struct node *node)
{
- size_t n = strspn(node->name, c->data);
+ size_t n;
+
+ if ((dti->dtsflags & DTSF_ADDON) && node_is_orphan(dti, node))
+ return; /* Checking name doesn't make sense for an orphan node */
+
+ n = strspn(node->name, c->data);
if (n < node->basenamelen)
FAIL(c, dti, node, "Character '%c' not recommended in node name",
@@ -628,6 +642,15 @@ static void fixup_phandle_references(struct check *c, struct dt_info *dti,
cpu_to_fdt32(0xffffffff);
continue;
}
+ if (node_is_orphan(dti, refnode)) {
+ if (!(dti->dtsflags & DTSF_ADDON))
+ FAIL(c, dti, node, "Reference to orphan node \"%s\"\n",
+ m->ref);
+ else /* mark the entry as unresolved */
+ *((fdt32_t *)(prop->val.val + m->offset)) =
+ cpu_to_fdt32(0xffffffff);
+ continue;
+ }
phandle = get_node_phandle(dti, refnode);
*((fdt32_t *)(prop->val.val + m->offset)) = cpu_to_fdt32(phandle);
--
2.55.0