[Pdbg] [PATCH v2 03/11] libpdbg/device: Remove unused device tree functions

Amitay Isaacs amitay at ozlabs.org
Thu Apr 12 16:01:52 AEST 2018


From: Alistair Popple <alistair at popple.id.au>

None of these are likely to ever get used

Signed-off-by: Cyril Bur <cyrilbur at gmail.com>
---
 libpdbg/device.c | 106 -------------------------------------------------------
 libpdbg/device.h |  13 -------
 2 files changed, 119 deletions(-)

diff --git a/libpdbg/device.c b/libpdbg/device.c
index e7b8ee0..3fefb11 100644
--- a/libpdbg/device.c
+++ b/libpdbg/device.c
@@ -150,102 +150,6 @@ static inline void dt_destroy(struct dt_node *dn)
 	free(dn);
 }
 
-struct dt_node *dt_new(struct dt_node *parent, const char *name)
-{
-	struct dt_node *new;
-	assert(parent);
-
-	new = new_node(name);
-	if (!dt_attach_root(parent, new)) {
-		dt_destroy(new);
-		return NULL;
-	}
-	return new;
-}
-
-struct dt_node *dt_new_addr(struct dt_node *parent, const char *name,
-			    uint64_t addr)
-{
-	char *lname;
-	struct dt_node *new;
-	size_t len;
-
-	assert(parent);
-	len = strlen(name) + STR_MAX_CHARS(addr) + 2;
-	lname = malloc(len);
-	if (!lname)
-		return NULL;
-	snprintf(lname, len, "%s@%llx", name, (long long)addr);
-	new = new_node(lname);
-	free(lname);
-	if (!dt_attach_root(parent, new)) {
-		dt_destroy(new);
-		return NULL;
-	}
-	return new;
-}
-
-struct dt_node *dt_new_2addr(struct dt_node *parent, const char *name,
-			     uint64_t addr0, uint64_t addr1)
-{
-	char *lname;
-	struct dt_node *new;
-	size_t len;
-	assert(parent);
-
-	len = strlen(name) + 2*STR_MAX_CHARS(addr0) + 3;
-	lname = malloc(len);
-	if (!lname)
-		return NULL;
-	snprintf(lname, len, "%s@%llx,%llx",
-		 name, (long long)addr0, (long long)addr1);
-	new = new_node(lname);
-	free(lname);
-	if (!dt_attach_root(parent, new)) {
-		dt_destroy(new);
-		return NULL;
-	}
-	return new;
-}
-
-static struct dt_node *__dt_copy(struct dt_node *node, struct dt_node *parent,
-		bool root)
-{
-	struct dt_property *prop, *new_prop;
-	struct dt_node *new_node, *child;
-
-	new_node = dt_new(parent, node->name);
-	if (!new_node)
-		return NULL;
-
-	list_for_each(&node->properties, prop, list) {
-		new_prop = dt_add_property(new_node, prop->name, prop->prop,
-				prop->len);
-		if (!new_prop)
-			goto fail;
-	}
-
-	list_for_each(&node->children, child, list) {
-		child = __dt_copy(child, new_node, false);
-		if (!child)
-			goto fail;
-	}
-
-	return new_node;
-
-fail:
-	/* dt_free will recurse for us, so only free when we unwind to the
-	 * top-level failure */
-	if (root)
-		dt_free(new_node);
-	return NULL;
-}
-
-struct dt_node *dt_copy(struct dt_node *node, struct dt_node *parent)
-{
-	return __dt_copy(node, parent, true);
-}
-
 char *dt_get_path(const struct dt_node *node)
 {
 	unsigned int len = 0;
@@ -360,16 +264,6 @@ struct dt_node *dt_find_by_name(struct dt_node *root, const char *name)
 	return NULL;
 }
 
-struct dt_node *dt_find_by_phandle(struct dt_node *root, u32 phandle)
-{
-	struct dt_node *node;
-
-	dt_for_each_node(root, node)
-		if (node->phandle == phandle)
-			return node;
-	return NULL;
-}
-
 static struct dt_property *new_property(struct dt_node *node,
 					const char *name, size_t size)
 {
diff --git a/libpdbg/device.h b/libpdbg/device.h
index 4bc60a7..bb0b3fa 100644
--- a/libpdbg/device.h
+++ b/libpdbg/device.h
@@ -62,16 +62,6 @@ struct dt_node *dt_new_root(const char *name);
 /* Graft a root node into this tree. */
 bool dt_attach_root(struct dt_node *parent, struct dt_node *root);
 
-/* Add a child node. */
-struct dt_node *dt_new(struct dt_node *parent, const char *name);
-struct dt_node *dt_new_addr(struct dt_node *parent, const char *name,
-			    uint64_t unit_addr);
-struct dt_node *dt_new_2addr(struct dt_node *parent, const char *name,
-			     uint64_t unit_addr0, uint64_t unit_addr1);
-
-/* Copy node to new parent, including properties and subnodes */
-struct dt_node *dt_copy(struct dt_node *node, struct dt_node *parent);
-
 /* Add a property node, various forms. */
 struct dt_property *dt_add_property(struct dt_node *node,
 				    const char *name,
@@ -178,9 +168,6 @@ struct dt_node *dt_find_by_path(struct dt_node *root, const char *path);
 /* Find a child node by name */
 struct dt_node *dt_find_by_name(struct dt_node *root, const char *name);
 
-/* Find a node by phandle */
-struct dt_node *dt_find_by_phandle(struct dt_node *root, u32 phandle);
-
 /* Find a property by name. */
 struct dt_property *dt_find_property(const struct dt_node *node,\
 				     const char *name);
-- 
2.14.3



More information about the Pdbg mailing list