[POWERPC] bootwrapper: Add ft_root_node().
Clean up some of the open-coded data structure references by providing a function to return a pointer to the tree's root node. This is only used in high-level functions trying to access the root of the tree, not in low-level code that is actually manipulating the data structure. Signed-off-by: Scott Wood <scottwood@freescale.com> Acked-by: Mark A. Greer <mgreer@mvista.com> Acked-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Paul Mackerras <paulus@samba.org>
This commit is contained in:
committed by
Paul Mackerras
parent
ce3edb30ec
commit
7c71c04625
@@ -29,6 +29,11 @@
|
|||||||
|
|
||||||
#define _ALIGN(x, al) (((x) + (al) - 1) & ~((al) - 1))
|
#define _ALIGN(x, al) (((x) + (al) - 1) & ~((al) - 1))
|
||||||
|
|
||||||
|
static char *ft_root_node(struct ft_cxt *cxt)
|
||||||
|
{
|
||||||
|
return cxt->rgn[FT_STRUCT].start;
|
||||||
|
}
|
||||||
|
|
||||||
/* Routines for keeping node ptrs returned by ft_find_device current */
|
/* Routines for keeping node ptrs returned by ft_find_device current */
|
||||||
/* First entry not used b/c it would return 0 and be taken as NULL/error */
|
/* First entry not used b/c it would return 0 and be taken as NULL/error */
|
||||||
static void *ft_node_add(struct ft_cxt *cxt, char *node)
|
static void *ft_node_add(struct ft_cxt *cxt, char *node)
|
||||||
@@ -590,7 +595,7 @@ int ft_add_rsvmap(struct ft_cxt *cxt, u64 physaddr, u64 size)
|
|||||||
|
|
||||||
void ft_begin_tree(struct ft_cxt *cxt)
|
void ft_begin_tree(struct ft_cxt *cxt)
|
||||||
{
|
{
|
||||||
cxt->p = cxt->rgn[FT_STRUCT].start;
|
cxt->p = ft_root_node(cxt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ft_end_tree(struct ft_cxt *cxt)
|
void ft_end_tree(struct ft_cxt *cxt)
|
||||||
@@ -636,7 +641,7 @@ void *ft_find_device(struct ft_cxt *cxt, const char *srch_path)
|
|||||||
/* require absolute path */
|
/* require absolute path */
|
||||||
if (srch_path[0] != '/')
|
if (srch_path[0] != '/')
|
||||||
return NULL;
|
return NULL;
|
||||||
node = ft_find_descendent(cxt, cxt->rgn[FT_STRUCT].start, srch_path);
|
node = ft_find_descendent(cxt, ft_root_node(cxt), srch_path);
|
||||||
return ft_node_add(cxt, node);
|
return ft_node_add(cxt, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -717,7 +722,7 @@ void *ft_get_parent(struct ft_cxt *cxt, const void *phandle)
|
|||||||
return cxt->genealogy[d > 0 ? d - 1 : 0];
|
return cxt->genealogy[d > 0 ? d - 1 : 0];
|
||||||
|
|
||||||
/* have to do it the hard way... */
|
/* have to do it the hard way... */
|
||||||
p = cxt->rgn[FT_STRUCT].start;
|
p = ft_root_node(cxt);
|
||||||
d = 0;
|
d = 0;
|
||||||
while ((p = ft_next(cxt, p, &atom)) != NULL) {
|
while ((p = ft_next(cxt, p, &atom)) != NULL) {
|
||||||
switch (atom.tag) {
|
switch (atom.tag) {
|
||||||
@@ -855,7 +860,7 @@ void *ft_create_node(struct ft_cxt *cxt, const void *parent, const char *path)
|
|||||||
char *p, *next;
|
char *p, *next;
|
||||||
int depth = 0;
|
int depth = 0;
|
||||||
|
|
||||||
p = cxt->rgn[FT_STRUCT].start;
|
p = ft_root_node(cxt);
|
||||||
while ((next = ft_next(cxt, p, &atom)) != NULL) {
|
while ((next = ft_next(cxt, p, &atom)) != NULL) {
|
||||||
switch (atom.tag) {
|
switch (atom.tag) {
|
||||||
case OF_DT_BEGIN_NODE:
|
case OF_DT_BEGIN_NODE:
|
||||||
|
Reference in New Issue
Block a user