Skip to contentSkip to conversation

checks: Change node-name check to match devicetree spec

PATCH Superseded Kumar Gala 3 participants 5 messages Feb 9, 2021 – Feb 10, 2021 2 messages not in the archive

lore
Share & tools
lore

Kumar Gala

author
#0 lore raw

PATCH 1/1 checks: Change node-name check to match devicetree spec

The devicetree spec limits the valid character set to:
A-Z
a-z
0-9
,._+-

while property can additionally have '?#'. Change the check to match the spec.

---
 checks.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
checks.c +4 -3
index 17cb689..24e6816 100644
@@ -297,7 +297,8 @@ ERROR(duplicate_property_names, check_duplicate_property_names, NULL);
 #define LOWERCASE	"abcdefghijklmnopqrstuvwxyz"
 #define UPPERCASE	"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
 #define DIGITS		"0123456789"
-#define PROPNODECHARS	LOWERCASE UPPERCASE DIGITS ",._+*#?-"
+#define NODECHARS	LOWERCASE UPPERCASE DIGITS ",._+-"
+#define PROPCHARS	LOWERCASE UPPERCASE DIGITS ",._+*#?-"
 #define PROPNODECHARSSTRICT	LOWERCASE UPPERCASE DIGITS ",-"
 
 static void check_node_name_chars(struct check *c, struct dt_info *dti,
@@ -309,7 +310,7 @@ static void check_node_name_chars(struct check *c, struct dt_info *dti,
 		FAIL(c, dti, node, "Bad character '%c' in node name",
 		     node->name[n]);
 }
-ERROR(node_name_chars, check_node_name_chars, PROPNODECHARS "@");
+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)
@@ -370,7 +371,7 @@ static void check_property_name_chars(struct check *c, struct dt_info *dti,
 				  prop->name[n]);
 	}
 }
-ERROR(property_name_chars, check_property_name_chars, PROPNODECHARS);
+ERROR(property_name_chars, check_property_name_chars, PROPCHARS);
 
 static void check_property_name_chars_strict(struct check *c,
 					     struct dt_info *dti,
Signature · 1 line
2.29.2

A message that is not in the archive (sent off-list or not yet received): 20210209172451.56967-1-kumar.gala-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org

#2 lore raw
Quoted 30 lines · Kumar Gala

The devicetree spec limits the valid character set to:
A-Z
a-z
0-9
,._+-

while property can additionally have '?#'. Change the check to match the spec.

---
 checks.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
checks.c +2 -1
index 17cb689..24e6816 100644
@@ -297,7 +297,8 @@ ERROR(duplicate_property_names, check_duplicate_property_names, NULL);
 #define LOWERCASE      "abcdefghijklmnopqrstuvwxyz"
 #define UPPERCASE      "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
 #define DIGITS         "0123456789"
-#define PROPNODECHARS  LOWERCASE UPPERCASE DIGITS ",._+*#?-"
+#define NODECHARS      LOWERCASE UPPERCASE DIGITS ",._+-"
+#define PROPCHARS      LOWERCASE UPPERCASE DIGITS ",._+*#?-"
 #define PROPNODECHARSSTRICT    LOWERCASE UPPERCASE DIGITS ",-"
 
 static void check_node_name_chars(struct check *c, struct dt_info *dti,

checks.c static void check_node_name_chars(struct check *c, struct dt_info *dti, · line 313

Quoted 5 lines
checks.c +1 -1
@@ -309,7 +310,7 @@ static void check_node_name_chars(struct check *c, struct dt_info *dti,
                FAIL(c, dti, node, "Bad character '%c' in node name",
                     node->name[n]);
 }
-ERROR(node_name_chars, check_node_name_chars, PROPNODECHARS "@");
+ERROR(node_name_chars, check_node_name_chars, NODECHARS "@");

Since we split the character sets, you should just add '@' to NODECHARS.

Quoted 15 lines
checks.c +1 -2
 static void check_node_name_chars_strict(struct check *c, struct dt_info *dti,
                                         struct node *node)
@@ -370,7 +371,7 @@ static void check_property_name_chars(struct check *c, struct dt_info *dti,
                                  prop->name[n]);
        }
 }
-ERROR(property_name_chars, check_property_name_chars, PROPNODECHARS);
+ERROR(property_name_chars, check_property_name_chars, PROPCHARS);
 
 static void check_property_name_chars_strict(struct check *c,
                                             struct dt_info *dti,
--

2.29.2

author
#3 lore raw

PATCH v2 1/1 checks: Error on node-name and property name being the same

In reply to a message not in the archive

Treat a node-name and property name at the same level of tree as an error.

---
 checks.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
checks.c +18 -1
index 17cb689..4d1a4ef 100644
@@ -330,6 +330,23 @@ static void check_node_name_format(struct check *c, struct dt_info *dti,
 }
 ERROR(node_name_format, check_node_name_format, NULL, &node_name_chars);
 
+static void check_node_name_vs_property_name(struct check *c,
+					     struct dt_info *dti,
+					     struct node *node)
+{
+	struct property *prop;
+
+	if (!node->parent)
+		return;
+
+	for_each_property(node->parent, prop) {
+		if (streq(node->name, prop->name))
+			FAIL(c, dti, node, "node name and property name conflict");
+	}
+}
+ERROR(node_name_vs_property_name, check_node_name_vs_property_name,
+      NULL, &node_name_chars);
+
 static void check_unit_address_vs_reg(struct check *c, struct dt_info *dti,
 				      struct node *node)
 {
@@ -1796,7 +1813,7 @@ WARNING(graph_endpoint, check_graph_endpoint, NULL, &graph_nodes);
 static struct check *check_table[] = {
 	&duplicate_node_names, &duplicate_property_names,
 	&node_name_chars, &node_name_format, &property_name_chars,
-	&name_is_string, &name_properties,
+	&name_is_string, &name_properties, &node_name_vs_property_name,
 
 	&duplicate_label,
 
Signature · 1 line
2.29.2
author
#4 lore raw

PATCH v2 1/1 checks: Change node-name check to match devicetree spec

In reply to a message not in the archive

The devicetree spec limits the valid character set to:
A-Z
a-z
0-9
,._+-

while property can additionally have '?#'. Change the check to match the spec.

---
 checks.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
checks.c +4 -3
index 17cb689..48e7fe9 100644
@@ -297,7 +297,8 @@ ERROR(duplicate_property_names, check_duplicate_property_names, NULL);
 #define LOWERCASE	"abcdefghijklmnopqrstuvwxyz"
 #define UPPERCASE	"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
 #define DIGITS		"0123456789"
-#define PROPNODECHARS	LOWERCASE UPPERCASE DIGITS ",._+*#?-"
+#define NODECHARS	LOWERCASE UPPERCASE DIGITS ",._+-@"
+#define PROPCHARS	LOWERCASE UPPERCASE DIGITS ",._+*#?-"
 #define PROPNODECHARSSTRICT	LOWERCASE UPPERCASE DIGITS ",-"
 
 static void check_node_name_chars(struct check *c, struct dt_info *dti,
@@ -309,7 +310,7 @@ static void check_node_name_chars(struct check *c, struct dt_info *dti,
 		FAIL(c, dti, node, "Bad character '%c' in node name",
 		     node->name[n]);
 }
-ERROR(node_name_chars, check_node_name_chars, PROPNODECHARS "@");
+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)
@@ -370,7 +371,7 @@ static void check_property_name_chars(struct check *c, struct dt_info *dti,
 				  prop->name[n]);
 	}
 }
-ERROR(property_name_chars, check_property_name_chars, PROPNODECHARS);
+ERROR(property_name_chars, check_property_name_chars, PROPCHARS);
 
 static void check_property_name_chars_strict(struct check *c,
 					     struct dt_info *dti,
Signature · 1 line
2.29.2

A message that is not in the archive (sent off-list or not yet received): 20210209184641.63052-1-kumar.gala-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org

Applied
#6 lore raw
Quoted 10 lines · Kumar Gala

The devicetree spec limits the valid character set to:
A-Z
a-z
0-9
,._+-

while property can additionally have '?#'. Change the check to match the spec.

Applied, thanks.

Quoted 36 lines
---
 checks.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
checks.c +4 -3
index 17cb689..48e7fe9 100644
@@ -297,7 +297,8 @@ ERROR(duplicate_property_names, check_duplicate_property_names, NULL);
 #define LOWERCASE	"abcdefghijklmnopqrstuvwxyz"
 #define UPPERCASE	"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
 #define DIGITS		"0123456789"
-#define PROPNODECHARS	LOWERCASE UPPERCASE DIGITS ",._+*#?-"
+#define NODECHARS	LOWERCASE UPPERCASE DIGITS ",._+-@"
+#define PROPCHARS	LOWERCASE UPPERCASE DIGITS ",._+*#?-"
 #define PROPNODECHARSSTRICT	LOWERCASE UPPERCASE DIGITS ",-"
 
 static void check_node_name_chars(struct check *c, struct dt_info *dti,
@@ -309,7 +310,7 @@ static void check_node_name_chars(struct check *c, struct dt_info *dti,
 		FAIL(c, dti, node, "Bad character '%c' in node name",
 		     node->name[n]);
 }
-ERROR(node_name_chars, check_node_name_chars, PROPNODECHARS "@");
+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)
@@ -370,7 +371,7 @@ static void check_property_name_chars(struct check *c, struct dt_info *dti,
 				  prop->name[n]);
 	}
 }
-ERROR(property_name_chars, check_property_name_chars, PROPNODECHARS);
+ERROR(property_name_chars, check_property_name_chars, PROPCHARS);
 
 static void check_property_name_chars_strict(struct check *c,
 					     struct dt_info *dti,
Signature · 4 lines
David Gibson			| 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