aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/of/selftest.c
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@linaro.org>2014-10-02 09:36:46 -0400
committerGrant Likely <grant.likely@linaro.org>2014-10-04 16:24:35 -0400
commit2eb46da2a760e5764c48b752a5ef320e02b96b21 (patch)
tree4d48a347c24c466d5bfe11b33e878585507daa74 /drivers/of/selftest.c
parent7941b27b16e3282f6ec8817e36492f1deec753a7 (diff)
of/selftest: Use the resolver to fixup phandles
The selftest data ends up causing duplicate phandles in the live tree for the time that the testcase data is inserted into the live tree. This is obviously a bad situation because anything attempting to read the tree while the selftests are running make resolve phandles to one of the testcase data nodes. Fix the problem by using the of_resolve_phandles() function to eliminate duplicates. Signed-off-by: Grant Likely <grant.likely@linaro.org> Cc: Pantelis Antoniou <pantelis.antoniou@konsulko.com> Cc: Gaurav Minocha <gaurav.minocha.os@gmail.com>
Diffstat (limited to 'drivers/of/selftest.c')
-rw-r--r--drivers/of/selftest.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/of/selftest.c b/drivers/of/selftest.c
index 4f83e97f8788..4fed34bff5cf 100644
--- a/drivers/of/selftest.c
+++ b/drivers/of/selftest.c
@@ -25,7 +25,7 @@ static struct selftest_results {
25 int failed; 25 int failed;
26} selftest_results; 26} selftest_results;
27 27
28#define NO_OF_NODES 2 28#define NO_OF_NODES 3
29static struct device_node *nodes[NO_OF_NODES]; 29static struct device_node *nodes[NO_OF_NODES];
30static int last_node_index; 30static int last_node_index;
31static bool selftest_live_tree; 31static bool selftest_live_tree;
@@ -765,6 +765,7 @@ static int __init selftest_data_add(void)
765 extern uint8_t __dtb_testcases_begin[]; 765 extern uint8_t __dtb_testcases_begin[];
766 extern uint8_t __dtb_testcases_end[]; 766 extern uint8_t __dtb_testcases_end[];
767 const int size = __dtb_testcases_end - __dtb_testcases_begin; 767 const int size = __dtb_testcases_end - __dtb_testcases_begin;
768 int rc;
768 769
769 if (!size) { 770 if (!size) {
770 pr_warn("%s: No testcase data to attach; not running tests\n", 771 pr_warn("%s: No testcase data to attach; not running tests\n",
@@ -785,6 +786,12 @@ static int __init selftest_data_add(void)
785 pr_warn("%s: No tree to attach; not running tests\n", __func__); 786 pr_warn("%s: No tree to attach; not running tests\n", __func__);
786 return -ENODATA; 787 return -ENODATA;
787 } 788 }
789 of_node_set_flag(selftest_data_node, OF_DETACHED);
790 rc = of_resolve_phandles(selftest_data_node);
791 if (rc) {
792 pr_err("%s: Failed to resolve phandles (rc=%i)\n", __func__, rc);
793 return -EINVAL;
794 }
788 795
789 if (!of_allnodes) { 796 if (!of_allnodes) {
790 /* enabling flag for removing nodes */ 797 /* enabling flag for removing nodes */