1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
From: Michael Olbrich <m.olbrich@pengutronix.de>
Date: Tue, 13 Sep 2016 21:17:12 +0200
Subject: [PATCH] of: base: add funtion to copy a device tree node
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
---
drivers/of/base.c | 16 ++++++++++++++++
include/of.h | 2 ++
2 files changed, 18 insertions(+)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index fb4d2c03946e..3ca13ae44e5c 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1988,6 +1988,22 @@ out:
return dn;
}
+struct device_node *of_copy_node(struct device_node *parent, const struct device_node *other)
+{
+ struct device_node *np, *child;
+ struct property *pp;
+
+ np = of_new_node(parent, other->name);
+
+ list_for_each_entry(pp, &other->properties, list)
+ of_new_property(np, pp->name, pp->value, pp->length);
+
+ for_each_child_of_node(other, child)
+ of_copy_node(np, child);
+
+ return np;
+}
+
void of_delete_node(struct device_node *node)
{
struct device_node *n, *nt;
diff --git a/include/of.h b/include/of.h
index 9ba771a395b8..18a423241b0f 100644
--- a/include/of.h
+++ b/include/of.h
@@ -144,6 +144,8 @@ extern struct device_node *of_new_node(struct device_node *parent,
const char *name);
extern struct device_node *of_create_node(struct device_node *root,
const char *path);
+extern struct device_node *of_copy_node(struct device_node *parent,
+ const struct device_node *other);
extern void of_delete_node(struct device_node *node);
extern int of_machine_is_compatible(const char *compat);
|