|
@@ -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;
|
|
|
}
|