2019-01-24 23:23:51

by Frank Rowand

[permalink] [raw]
Subject: [PATCH 0/2] 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(-)

--
Frank Rowand <[email protected]>



2019-01-24 23:24:29

by Frank Rowand

[permalink] [raw]
Subject: [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.

Signed-off-by: Frank Rowand <[email protected]>
---
drivers/of/unittest.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index 84427384654d..3249fe259d30 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -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);
+ }
}
}

--
Frank Rowand <[email protected]>


2019-01-24 23:24:54

by Frank Rowand

[permalink] [raw]
Subject: [PATCH 2/2] of: unittest: add caution to function header comment

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.

Signed-off-by: Frank Rowand <[email protected]>
---
drivers/of/unittest.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index 3249fe259d30..872956500c27 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -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
*/
--
Frank Rowand <[email protected]>


2019-02-14 00:46:49

by Rob Herring (Arm)

[permalink] [raw]
Subject: Re: [PATCH 0/2] of: unittest: minor cleanups

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