Skip to contentSkip to conversation

of: unittest: minor cleanups

PATCH Applied [email protected] 2 participants 4 messages Jan 24, 2019 – Feb 13, 2019 Device tree

lore
Share & tools
lore
#0 lore raw

cover of: unittest: minor cleanups

From: Frank Rowand <[email protected]>

1) Suppress expected error message when adding unittest data to livetree.

2) While writing patch 1, noted a misleading function name. Add comment to the function header warning about possible unexpected results.

Frank Rowand (2):
of: unittest: remove report of expected error
of: unittest: add caution to function header comment

 drivers/of/unittest.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
Signature · 1 line
Frank Rowand <[email protected]>
#1 lore raw

PATCH 1/2 of: unittest: remove report of expected error

From: Frank Rowand <[email protected]>

update_node_properties() reports an error when the test data contains a node (such as "/aliases") that already exists in the base devicetree. The error is caused by of_fdt_unflatten_tree() autogenerating the "name" property, thus both the existing node and the new node will have a property with the same name. Suppress reporting the known error.

---
 drivers/of/unittest.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/of/unittest.c +4 -1
index 84427384654d..3249fe259d30 100644
@@ -1116,9 +1116,12 @@ static void update_node_properties(struct device_node *np,
 	for (prop = np->properties; prop != NULL; prop = save_next) {
 		save_next = prop->next;
 		ret = of_add_property(dup, prop);
-		if (ret)
+		if (ret) {
+			if (ret == -EEXIST && !strcmp(prop->name, "name"))
+				continue;
 			pr_err("unittest internal error: unable to add testdata property %pOF/%s",
 			       np, prop->name);
+		}
 	}
 }
 
Signature · 1 line
Frank Rowand <[email protected]>
#2 lore raw

PATCH 2/2 of: unittest: add caution to function header comment

In reply to [email protected]

From: Frank Rowand <[email protected]>

Name of function attach_node_and_children() is misleading because if the node already exists in the livetree then only the node's properties are attached. This works for the existing test data, but add comment warning of this misleading name.

---
 drivers/of/unittest.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/of/unittest.c +5 -1
index 3249fe259d30..872956500c27 100644
@@ -1127,7 +1127,11 @@ static void update_node_properties(struct device_node *np,
 
 /**
  *	attach_node_and_children - attaches nodes
- *	and its children to live tree
+ *	and its children to live tree.
+ *	CAUTION: misleading function name - if node @np already exists in
+ *	the live tree then children of @np are *not* attached to the live
+ *	tree.  This works for the current test devicetree nodes because such
+ *	nodes do not have child nodes.
  *
  *	@np:	Node to attach to live tree
  */
Signature · 1 line
Frank Rowand <[email protected]>
maintainer Applied
#3 lore raw
In reply to [email protected]
Quoted 11 lines · On Thu, Jan 24, 2019 at 03:22:12PM -0800, [email protected] wrote:

From: Frank Rowand <[email protected]>

1) Suppress expected error message when adding unittest data to livetree.

2) While writing patch 1, noted a misleading function name. Add comment to the function header warning about possible unexpected results.

Frank Rowand (2):
of: unittest: remove report of expected error
of: unittest: add caution to function header comment

Applied.

Rob