* [PATCH 1/2] checks: Allow "__overlay__" node at the root of an overlay fragment
@ 2025-11-10 20:45 Douglas Anderson
2025-11-10 20:45 ` [PATCH 2/2] checks: Allow "chosen" node under "__overlay__" for a DT fragment Douglas Anderson
0 siblings, 1 reply; 2+ messages in thread
From: Douglas Anderson @ 2025-11-10 20:45 UTC (permalink / raw)
To: Rob Herring, Saravana Kannan; +Cc: devicetree, linux-kernel, Douglas Anderson
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.
Signed-off-by: Douglas Anderson <dianders@chromium.org>
---
checks.c | 33 ++++++++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/checks.c b/checks.c
index 5d092164ee12..908df5b98ec5 100644
--- a/checks.c
+++ b/checks.c
@@ -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]);
--
2.51.2.1041.gc1ab5b90ca-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 2/2] checks: Allow "chosen" node under "__overlay__" for a DT fragment
2025-11-10 20:45 [PATCH 1/2] checks: Allow "__overlay__" node at the root of an overlay fragment Douglas Anderson
@ 2025-11-10 20:45 ` Douglas Anderson
0 siblings, 0 replies; 2+ messages in thread
From: Douglas Anderson @ 2025-11-10 20:45 UTC (permalink / raw)
To: Rob Herring, Saravana Kannan; +Cc: devicetree, linux-kernel, Douglas Anderson
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.
Signed-off-by: Douglas Anderson <dianders@chromium.org>
---
checks.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/checks.c b/checks.c
index 908df5b98ec5..d28e59494757 100644
--- a/checks.c
+++ b/checks.c
@@ -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);
--
2.51.2.1041.gc1ab5b90ca-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-11-10 20:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-10 20:45 [PATCH 1/2] checks: Allow "__overlay__" node at the root of an overlay fragment Douglas Anderson
2025-11-10 20:45 ` [PATCH 2/2] checks: Allow "chosen" node under "__overlay__" for a DT fragment Douglas Anderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).