[PATCH 10/18] bootwrapper: Add ft_find_device_rel().

Subsystems: linux for powerpc (32-bit and 64-bit), the rest

STALE7135d

3 messages, 2 authors, 2007-01-30 · open the first message on its own page

[PATCH 10/18] bootwrapper: Add ft_find_device_rel().

From: Scott Wood <hidden>
Date: 2007-01-29 20:12:11

Add a function to look up a relative, rather than absolute, path name.

Signed-off-by: Scott Wood <redacted>
---
 arch/powerpc/boot/flatdevtree.c |   13 +++++++++++++
 arch/powerpc/boot/flatdevtree.h |    2 ++
 2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/arch/powerpc/boot/flatdevtree.c b/arch/powerpc/boot/flatdevtree.c
index e319a65..bd006f7 100644
--- a/arch/powerpc/boot/flatdevtree.c
+++ b/arch/powerpc/boot/flatdevtree.c
@@ -654,6 +654,19 @@ void *ft_find_device(struct ft_cxt *cxt,
 	return ft_get_phandle(cxt, node);
 }
 
+void *ft_find_device_rel(struct ft_cxt *cxt, const void *top,
+                         const char *srch_path)
+{
+	char *node;
+
+	node = ft_node_ph2node(cxt, top);
+	if (node == NULL)
+		return NULL;
+
+	node = ft_find_descendent(cxt, node, srch_path);
+	return ft_get_phandle(cxt, node);
+}
+
 void *ft_find_descendent(struct ft_cxt *cxt, void *top, const char *srch_path)
 {
 	struct ft_atom atom;
diff --git a/arch/powerpc/boot/flatdevtree.h b/arch/powerpc/boot/flatdevtree.h
index b9cd9f6..1f37ca2 100644
--- a/arch/powerpc/boot/flatdevtree.h
+++ b/arch/powerpc/boot/flatdevtree.h
@@ -97,6 +97,8 @@ int ft_add_rsvmap(struct ft_cxt *cxt, u6
 void ft_dump_blob(const void *bphp);
 void ft_merge_blob(struct ft_cxt *cxt, void *blob);
 void *ft_find_device(struct ft_cxt *cxt, const char *srch_path);
+void *ft_find_device_rel(struct ft_cxt *cxt, const void *top,
+                         const char *srch_path);
 void *ft_find_descendent(struct ft_cxt *cxt, void *top, const char *srch_path);
 int ft_get_prop(struct ft_cxt *cxt, const void *phandle, const char *propname,
 		void *buf, const unsigned int buflen);
-- 
1.4.4

Re: [PATCH 10/18] bootwrapper: Add ft_find_device_rel().

From: Segher Boessenkool <hidden>
Date: 2007-01-30 19:54:10

+void *ft_find_device_rel(struct ft_cxt *cxt, const void *top,
+                         const char *srch_path)
+{
+	char *node;
+
+	node = ft_node_ph2node(cxt, top);
Huh -- are phandles a pointer?  Why not just a u32?
Or is _your_ code buggy ;-)  [No it's not, I checked]


Segher

Re: [PATCH 10/18] bootwrapper: Add ft_find_device_rel().

From: Scott Wood <hidden>
Date: 2007-01-30 20:25:50

Segher Boessenkool wrote:
quoted
+void *ft_find_device_rel(struct ft_cxt *cxt, const void *top,
+                         const char *srch_path)
+{
+    char *node;
+
+    node = ft_node_ph2node(cxt, top);

Huh -- are phandles a pointer?  Why not just a u32?
I can't speak for whoever designed the interface, but I'd rather keep it 
as a pointer -- it provides more flexibility to the implementation.  For 
example, if the device tree were to be maintained as a normal 
pointer-based tree, and flattened only when finalize() is called, then a 
pointer would be a natural handle to export (which wouldn't fit into a 
u32 on 64-bit platforms, unless you make assumptions about where 
bootwrapper data is located).

The downside, of course, is that it's easier to get phandles and 
internal pointers mixed up.

-Scott
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help