All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/9] bootwrapper: flatdevtree fixes
@ 2007-08-29 16:45 Scott Wood
  2007-08-29 16:46 ` [PATCH 2/9] bootwrapper: Add strtoull() Scott Wood
                   ` (7 more replies)
  0 siblings, 8 replies; 18+ messages in thread
From: Scott Wood @ 2007-08-29 16:45 UTC (permalink / raw)
  To: paulus; +Cc: linuxppc-dev

1. ft_create_node was returning the internal pointer rather than a phandle.
2. ft_find_device_rel was treating a "top" phandle of NULL as an error,
rather than as the root of the tree.  The old, absolute ft_find_device
is removed, and the relative version is renamed to ft_find_device().

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
 arch/powerpc/boot/flatdevtree.c      |   41 +++++++++++++++------------------
 arch/powerpc/boot/flatdevtree.h      |    7 ++---
 arch/powerpc/boot/flatdevtree_misc.c |    2 +-
 3 files changed, 23 insertions(+), 27 deletions(-)

diff --git a/arch/powerpc/boot/flatdevtree.c b/arch/powerpc/boot/flatdevtree.c
index 13761bf..0af7291 100644
--- a/arch/powerpc/boot/flatdevtree.c
+++ b/arch/powerpc/boot/flatdevtree.c
@@ -354,16 +354,21 @@ static void ft_put_bin(struct ft_cxt *cxt, const void *data, unsigned int sz)
 	cxt->p += sza;
 }
 
-int ft_begin_node(struct ft_cxt *cxt, const char *name)
+char *ft_begin_node(struct ft_cxt *cxt, const char *name)
 {
 	unsigned long nlen = strlen(name) + 1;
 	unsigned long len = 8 + _ALIGN(nlen, 4);
+	char *ret;
 
 	if (!ft_make_space(cxt, &cxt->p, FT_STRUCT, len))
-		return -1;
+		return NULL;
+
+	ret = cxt->p;
+
 	ft_put_word(cxt, OF_DT_BEGIN_NODE);
 	ft_put_bin(cxt, name, strlen(name) + 1);
-	return 0;
+
+	return ret;
 }
 
 void ft_end_node(struct ft_cxt *cxt)
@@ -625,25 +630,17 @@ void ft_end_tree(struct ft_cxt *cxt)
 	bph->dt_strings_size = cpu_to_be32(ssize);
 }
 
-void *ft_find_device(struct ft_cxt *cxt, const char *srch_path)
-{
-	char *node;
-
-	/* require absolute path */
-	if (srch_path[0] != '/')
-		return NULL;
-	node = ft_find_descendent(cxt, ft_root_node(cxt), srch_path);
-	return ft_get_phandle(cxt, node);
-}
-
-void *ft_find_device_rel(struct ft_cxt *cxt, const void *top,
-                         const char *srch_path)
+void *ft_find_device(struct ft_cxt *cxt, const void *top, const char *srch_path)
 {
 	char *node;
 
-	node = ft_node_ph2node(cxt, top);
-	if (node == NULL)
-		return NULL;
+	if (top) {
+		node = ft_node_ph2node(cxt, top);
+		if (node == NULL)
+			return NULL;
+	} else {
+		node = ft_root_node(cxt);
+	}
 
 	node = ft_find_descendent(cxt, node, srch_path);
 	return ft_get_phandle(cxt, node);
@@ -945,7 +942,7 @@ int ft_del_prop(struct ft_cxt *cxt, const void *phandle, const char *propname)
 void *ft_create_node(struct ft_cxt *cxt, const void *parent, const char *name)
 {
 	struct ft_atom atom;
-	char *p, *next;
+	char *p, *next, *ret;
 	int depth = 0;
 
 	if (parent) {
@@ -970,9 +967,9 @@ void *ft_create_node(struct ft_cxt *cxt, const void *parent, const char *name)
 				break;
 			/* end of node, insert here */
 			cxt->p = p;
-			ft_begin_node(cxt, name);
+			ret = ft_begin_node(cxt, name);
 			ft_end_node(cxt);
-			return p;
+			return ft_get_phandle(cxt, ret);
 		}
 		p = next;
 	}
diff --git a/arch/powerpc/boot/flatdevtree.h b/arch/powerpc/boot/flatdevtree.h
index cb26325..2c1c826 100644
--- a/arch/powerpc/boot/flatdevtree.h
+++ b/arch/powerpc/boot/flatdevtree.h
@@ -76,7 +76,7 @@ struct ft_cxt {
 	unsigned int nodes_used;
 };
 
-int ft_begin_node(struct ft_cxt *cxt, const char *name);
+char *ft_begin_node(struct ft_cxt *cxt, const char *name);
 void ft_end_node(struct ft_cxt *cxt);
 
 void ft_begin_tree(struct ft_cxt *cxt);
@@ -96,9 +96,8 @@ int ft_add_rsvmap(struct ft_cxt *cxt, u64 physaddr, u64 size);
 
 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_device(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);
diff --git a/arch/powerpc/boot/flatdevtree_misc.c b/arch/powerpc/boot/flatdevtree_misc.c
index 4341e65..8d1debe 100644
--- a/arch/powerpc/boot/flatdevtree_misc.c
+++ b/arch/powerpc/boot/flatdevtree_misc.c
@@ -18,7 +18,7 @@ static struct ft_cxt cxt;
 
 static void *fdtm_finddevice(const char *name)
 {
-	return ft_find_device(&cxt, name);
+	return ft_find_device(&cxt, NULL, name);
 }
 
 static int fdtm_getprop(const void *phandle, const char *propname,
-- 
1.5.0.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2007-08-31  3:24 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-29 16:45 [PATCH 1/9] bootwrapper: flatdevtree fixes Scott Wood
2007-08-29 16:46 ` [PATCH 2/9] bootwrapper: Add strtoull() Scott Wood
2007-08-30  0:30   ` David Gibson
2007-08-30 15:52   ` Milton Miller
2007-08-30 16:16     ` Scott Wood
2007-08-29 16:46 ` [PATCH 3/9] bootwrapper: Add get_path() Scott Wood
2007-08-30  0:30   ` David Gibson
2007-08-29 16:47 ` [PATCH 4/9] bootwrapper: Move strncmp() from flatdevtree_env.h to string.S/string.h Scott Wood
2007-08-30  0:31   ` David Gibson
2007-08-29 16:47 ` [PATCH 6/9] bootwrapper: Add a zImage.bin.<platform> target Scott Wood
2007-08-30  0:34   ` David Gibson
2007-08-30 14:21     ` Scott Wood
2007-08-31  3:24       ` David Gibson
2007-08-29 16:47 ` [PATCH 7/9] bootwrapper: Only print MAC addresses when the node is actually present Scott Wood
2007-08-30  0:34   ` David Gibson
2007-08-29 16:47 ` [PATCH 8/9] bootwrapper: Add fsl_get_immr() and 8xx/pq2 clock functions Scott Wood
2007-08-29 16:47 ` [PATCH 9/9] bootwrapper: Use fsl_get_immr() in cuboot-pq2.c Scott Wood
2007-08-30  0:28 ` [PATCH 1/9] bootwrapper: flatdevtree fixes David Gibson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.