aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGaurav Minocha <gaurav.minocha.os@gmail.com>2015-01-11 02:19:51 -0500
committerRob Herring <robh@kernel.org>2015-01-13 14:58:02 -0500
commit3ce04b4a9fdc30b6ec651e477dd08fee4e48f9aa (patch)
treef865fb235fc96de0780c2cc3c6dc888d6abadbc1
parent9a4305bde41e87a2c56b560ebd1783cf3fbbcea3 (diff)
Removes OF_UNITTEST dependency on OF_DYNAMIC config symbol
This patch intends to remove the unittests dependency on the functions defined in dynamic.c. So, rather than calling of_attach_node defined in dynamic.c, minimal functionality required to attach a new node is re-defined in unittest.c. Also, now after executing the tests the test data is not removed from the device tree so there is no need to call of_detach_node. Tested with and without OF_DYNAMIC enabled on ppc, arm and x86 Signed-off-by: Gaurav Minocha <gaurav.minocha.os@gmail.com> Signed-off-by: Rob Herring <robh@kernel.org>
-rw-r--r--drivers/of/Kconfig1
-rw-r--r--drivers/of/unittest.c70
2 files changed, 12 insertions, 59 deletions
diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
index b5e0c873d4e1..38d1c51f58b1 100644
--- a/drivers/of/Kconfig
+++ b/drivers/of/Kconfig
@@ -10,7 +10,6 @@ menu "Device Tree and Open Firmware support"
10config OF_UNITTEST 10config OF_UNITTEST
11 bool "Device Tree runtime unit tests" 11 bool "Device Tree runtime unit tests"
12 depends on OF_IRQ && OF_EARLY_FLATTREE 12 depends on OF_IRQ && OF_EARLY_FLATTREE
13 select OF_DYNAMIC
14 select OF_RESOLVE 13 select OF_RESOLVE
15 help 14 help
16 This option builds in test cases for the device tree infrastructure 15 This option builds in test cases for the device tree infrastructure
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index 844838e11ef1..139363af5c88 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -822,6 +822,7 @@ static void update_node_properties(struct device_node *np,
822static int attach_node_and_children(struct device_node *np) 822static int attach_node_and_children(struct device_node *np)
823{ 823{
824 struct device_node *next, *dup, *child; 824 struct device_node *next, *dup, *child;
825 unsigned long flags;
825 826
826 dup = of_find_node_by_path(np->full_name); 827 dup = of_find_node_by_path(np->full_name);
827 if (dup) { 828 if (dup) {
@@ -838,8 +839,17 @@ static int attach_node_and_children(struct device_node *np)
838 839
839 child = np->child; 840 child = np->child;
840 np->child = NULL; 841 np->child = NULL;
841 np->sibling = NULL; 842
842 of_attach_node(np); 843 mutex_lock(&of_mutex);
844 raw_spin_lock_irqsave(&devtree_lock, flags);
845 np->sibling = np->parent->child;
846 np->parent->child = np;
847 of_node_clear_flag(np, OF_DETACHED);
848 raw_spin_unlock_irqrestore(&devtree_lock, flags);
849
850 __of_attach_node_sysfs(np);
851 mutex_unlock(&of_mutex);
852
843 while (child) { 853 while (child) {
844 next = child->sibling; 854 next = child->sibling;
845 attach_node_and_children(child); 855 attach_node_and_children(child);
@@ -911,59 +921,6 @@ static int __init selftest_data_add(void)
911 return 0; 921 return 0;
912} 922}
913 923
914/**
915 * detach_node_and_children - detaches node
916 * and its children from live tree
917 *
918 * @np: Node to detach from live tree
919 */
920static void detach_node_and_children(struct device_node *np)
921{
922 while (np->child)
923 detach_node_and_children(np->child);
924 of_detach_node(np);
925}
926
927/**
928 * selftest_data_remove - removes the selftest data
929 * nodes from the live tree
930 */
931static void selftest_data_remove(void)
932{
933 struct device_node *np;
934 struct property *prop;
935
936 if (selftest_live_tree) {
937 of_node_put(of_aliases);
938 of_node_put(of_chosen);
939 of_aliases = NULL;
940 of_chosen = NULL;
941 for_each_child_of_node(of_root, np)
942 detach_node_and_children(np);
943 __of_detach_node_sysfs(of_root);
944 of_root = NULL;
945 return;
946 }
947
948 while (last_node_index-- > 0) {
949 if (nodes[last_node_index]) {
950 np = of_find_node_by_path(nodes[last_node_index]->full_name);
951 if (np == nodes[last_node_index]) {
952 if (of_aliases == np) {
953 of_node_put(of_aliases);
954 of_aliases = NULL;
955 }
956 detach_node_and_children(np);
957 } else {
958 for_each_property_of_node(np, prop) {
959 if (strcmp(prop->name, "testcase-alias") == 0)
960 of_remove_property(np, prop);
961 }
962 }
963 }
964 }
965}
966
967#ifdef CONFIG_OF_OVERLAY 924#ifdef CONFIG_OF_OVERLAY
968 925
969static int selftest_probe(struct platform_device *pdev) 926static int selftest_probe(struct platform_device *pdev)
@@ -1475,9 +1432,6 @@ static int __init of_selftest(void)
1475 of_selftest_platform_populate(); 1432 of_selftest_platform_populate();
1476 of_selftest_overlay(); 1433 of_selftest_overlay();
1477 1434
1478 /* removing selftest data from live tree */
1479 selftest_data_remove();
1480
1481 /* Double check linkage after removing testcase data */ 1435 /* Double check linkage after removing testcase data */
1482 of_selftest_check_tree_linkage(); 1436 of_selftest_check_tree_linkage();
1483 1437