9
0
Fork 0

of: parse phandles during unflatten

With this node->phandle becomes valid after unflattening a tree
and not during of_probe later.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Sascha Hauer 2013-08-13 15:13:15 +02:00
parent a5352dfb66
commit 7d505a9626
2 changed files with 7 additions and 19 deletions

View File

@ -1568,22 +1568,6 @@ int of_add_memory(struct device_node *node, bool dump)
return 0;
}
static void __of_parse_phandles(struct device_node *node)
{
struct device_node *n;
phandle phandle;
int ret;
ret = of_property_read_u32(node, "phandle", &phandle);
if (!ret) {
node->phandle = phandle;
list_add_tail(&node->phandles, &phandle_list);
}
list_for_each_entry(n, &node->children, parent_list)
__of_parse_phandles(n);
}
struct device_node *of_chosen;
const char *of_model;
@ -1602,7 +1586,7 @@ const struct of_device_id of_default_bus_match_table[] = {
int of_probe(void)
{
struct device_node *memory;
struct device_node *memory, *node;
if(!root_node)
return -ENODEV;
@ -1610,7 +1594,9 @@ int of_probe(void)
of_chosen = of_find_node_by_path("/chosen");
of_property_read_string(root_node, "model", &of_model);
__of_parse_phandles(root_node);
of_tree_for_each_node_from(node, root_node)
if (node->phandle)
list_add_tail(&node->phandles, &phandle_list);
memory = of_find_node_by_path("/memory");
if (memory)

View File

@ -188,7 +188,9 @@ struct device_node *of_unflatten_dtb(struct device_node *root, void *infdt)
p->length = len;
memcpy(p->value, nodep, len);
} else {
of_new_property(node, name, nodep, len);
p = of_new_property(node, name, nodep, len);
if (!strcmp(name, "phandle") && len == 4)
node->phandle = be32_to_cpup(p->value);
}
break;