Commit 788ec2fc authored by Grant Likely's avatar Grant Likely

of/selftest: Fix testing when /aliases is missing

The /aliases node isn't always present in the device tree, but the
unittest code assumes that /aliases is there. Add a check when inserting
the testcase data to see if of_aliases needs to be updated, and undo the
settings when the nodes are removed.
Signed-off-by: default avatarGrant Likely <grant.likely@linaro.org>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Gaurav Minocha <gaurav.minocha.os@gmail.com>
Cc: <stable@vger.kernel.org>
parent c1a2086e
...@@ -899,7 +899,11 @@ static void selftest_data_remove(void) ...@@ -899,7 +899,11 @@ static void selftest_data_remove(void)
while (last_node_index-- > 0) { while (last_node_index-- > 0) {
if (nodes[last_node_index]) { if (nodes[last_node_index]) {
np = of_find_node_by_path(nodes[last_node_index]->full_name); np = of_find_node_by_path(nodes[last_node_index]->full_name);
if (strcmp(np->full_name, "/aliases") != 0) { if (np == nodes[last_node_index]) {
if (of_aliases == np) {
of_node_put(of_aliases);
of_aliases = NULL;
}
detach_node_and_children(np); detach_node_and_children(np);
} else { } else {
for_each_property_of_node(np, prop) { for_each_property_of_node(np, prop) {
...@@ -920,6 +924,8 @@ static int __init of_selftest(void) ...@@ -920,6 +924,8 @@ static int __init of_selftest(void)
res = selftest_data_add(); res = selftest_data_add();
if (res) if (res)
return res; return res;
if (!of_aliases)
of_aliases = of_find_node_by_path("/aliases");
np = of_find_node_by_path("/testcase-data/phandle-tests/consumer-a"); np = of_find_node_by_path("/testcase-data/phandle-tests/consumer-a");
if (!np) { if (!np) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment