Skip to contentSkip to conversation

checks: Allow "__overlay__" node at the root of an overlay fragment

PATCH New Douglas Anderson 1 participant 2 messages Nov 10, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 checks: Allow "__overlay__" node at the root of an overlay fragment

Checking a dtso file will give the following warning:
Warning (node_name_chars_strict): /fragment@<num>/__overlay__: Character '_' not recommended in node name

Add the node named "__overlay__" at the root of a fragment as a special case to not warn about.

---

 checks.c | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)
checks.c +32 -1
index 5d092164ee12..908df5b98ec5 100644
@@ -192,6 +192,25 @@ out:
 	return error;
 }
 
+/* Return the path after "/fragment@<num>" or NULL if path doesn't start "/fragment@<num>/"" */
+static const char *get_fragment_relative_path(const char *fullpath)
+{
+	const char *p;
+
+	if (strncmp(fullpath, "/fragment@", 10) != 0)
+		return NULL;
+
+	p = &(fullpath[10]);
+	if (!isdigit(*p))
+		return NULL;
+	while (isdigit(*p))
+		p++;
+	if (*p != '/')
+		return NULL;
+
+	return p;
+}
+
 /*
  * Utility check functions
  */
@@ -324,8 +343,20 @@ 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)
 {
-	int n = strspn(node->name, c->data);
+	int n;
+
+	/*
+	 * The node named "__overlay__" is allowed at the root of a fragment
+	 * in an overlay.
+	 */
+	if (dti->dtsflags & DTSF_PLUGIN) {
+		const char *frag_path = get_fragment_relative_path(node->fullpath);
+
+		if (frag_path && streq(frag_path, "/__overlay__"))
+			return;
+	}
 
+	n = strspn(node->name, c->data);
 	if (n < node->basenamelen)
 		FAIL(c, dti, node, "Character '%c' not recommended in node name",
 		     node->name[n]);
Signature · 1 line
2.51.2.1041.gc1ab5b90ca-goog
#1 lore raw

PATCH 2/2 checks: Allow "chosen" node under "__overlay__" for a DT fragment

If a dtso file adds to the chosen node, a false warning will be reported:
Warning (chosen_node_is_root): /fragment@<num>/__overlay__/chosen: chosen node must be at root node

Allow the "chosen" node to be under the "__overlay__" node at the root of a fragment.

---

 checks.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
checks.c +11 -2
index 908df5b98ec5..d28e59494757 100644
@@ -1371,8 +1371,17 @@ static void check_chosen_node_is_root(struct check *c, struct dt_info *dti,
 	if (!streq(node->name, "chosen"))
 		return;
 
-	if (node->parent != dti->dt)
-		FAIL(c, dti, node, "chosen node must be at root node");
+	if (dti->dtsflags & DTSF_PLUGIN) {
+		const char *frag_path = get_fragment_relative_path(node->fullpath);
+
+		if (frag_path && streq(frag_path, "/__overlay__/chosen"))
+			return;
+	} else {
+		if (node->parent == dti->dt)
+			return;
+	}
+
+	FAIL(c, dti, node, "chosen node must be at root node");
 }
 WARNING(chosen_node_is_root, check_chosen_node_is_root, NULL);
 
Signature · 1 line
2.51.2.1041.gc1ab5b90ca-goog