Skip to contentSkip to conversation

of: refuse to delete root node of live tree

PATCH New Sascha Hauer 1 participant 2 messages Jun 25, 2021 Device tree

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 of: refuse to delete root node of live tree

The root node of the live tree should never be deleted, so refuse to do so and print an error message. Deleting the live tree was possible with the oftree -f command which was removed in c39c70bac5 ("commands: oftree:
kill oftree -f"). As this no longer exists we also do not need the of_set_root_node(NULL) part anymore.

---
 drivers/of/base.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/of/base.c +5 -3
index 5756f8b60a..551b41fc9e 100644
@@ -2441,6 +2441,11 @@ void of_delete_node(struct device_node *node)
 	if (!node)
 		return;
 
+	if (node == root_node) {
+		pr_err("Won't delete root device node\n");
+		return;
+	}
+
 	list_for_each_entry_safe(p, pt, &node->properties, list)
 		of_delete_property(p);
 
@@ -2459,9 +2464,6 @@ void of_delete_node(struct device_node *node)
 	free(node->name);
 	free(node->full_name);
 	free(node);
-
-	if (node == root_node)
-		of_set_root_node(NULL);
 }
 
 struct device_node *of_get_stdoutpath(void)
Signature · 7 lines
2.30.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH 2/2 of: Fix deep-probe triggering when removing nodes

During deletion of device nodes of_find_device_by_node() is called in order to set the device_node pointer of the device corresponding to the to-be-deleted node to NULL. This is not necessary anymore as the live tree should not be deleted.
This fixes problems with deep-probe support. of_find_device_by_node() calls of_device_ensure_probed(), but this may only be called on the live tree, not on arbitrary nodes that shall be deleted.

---
 drivers/of/base.c | 5 -----
 1 file changed, 5 deletions(-)
drivers/of/base.c +0 -5
index 551b41fc9e..9a8fdc81e8 100644
@@ -2436,7 +2436,6 @@ void of_delete_node(struct device_node *node)
 {
 	struct device_node *n, *nt;
 	struct property *p, *pt;
-	struct device_d *dev;
 
 	if (!node)
 		return;
@@ -2457,10 +2456,6 @@ void of_delete_node(struct device_node *node)
 		list_del(&node->list);
 	}
 
-	dev = of_find_device_by_node(node);
-	if (dev)
-		dev->device_node = NULL;
-
 	free(node->name);
 	free(node->full_name);
 	free(node);
Signature · 7 lines
2.30.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox