From 3b93bcd8db01bbe49249b59b0581b3ba375cb96b Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 24 Jun 2021 10:52:07 +0200 Subject: of: Add function to duplicate a device tree This adds of_dup() to duplicate a device tree. Previously of_copy_node() was used for this, but of_copy_node() has issues with potentially duplicated phandle values when the new tree is inserted to an existing tree, that is when the parent argument of of_copy_node() is non NULL. All users of of_copy_node() with a NULL parent argument are converted to of_dup() which is safe to use leaving only the problematic users of of_copy_node(). Signed-off-by: Sascha Hauer Link: https://lore.barebox.org/20210624085223.14616-3-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer --- drivers/of/base.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'drivers/of/base.c') diff --git a/drivers/of/base.c b/drivers/of/base.c index 1434f39ad1..5d93750aec 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -2420,6 +2420,11 @@ struct device_node *of_copy_node(struct device_node *parent, const struct device return np; } +struct device_node *of_dup(const struct device_node *root) +{ + return of_copy_node(NULL, root); +} + void of_delete_node(struct device_node *node) { struct device_node *n, *nt; -- cgit v1.2.3