9
0
Fork 0

of: parse phandles before probing devices

The phandles have to be parsed completely before registering the devices
from the devicetree. Otherwise drivers can't rely on of_find_node_by_phandle
in their probe.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Sascha Hauer 2013-04-21 16:27:35 +02:00
parent 43f9a96a74
commit 8e9d9bc7e6
1 changed files with 17 additions and 7 deletions

View File

@ -873,15 +873,8 @@ static int add_of_device_resource(struct device_node *node)
u64 address, size;
struct resource *res;
struct device_d *dev;
phandle phandle;
int ret;
ret = of_property_read_u32(node, "phandle", &phandle);
if (!ret) {
node->phandle = phandle;
list_add_tail(&node->phandles, &phandle_list);
}
ret = of_add_memory(node, false);
if (ret != -ENXIO)
return ret;
@ -975,6 +968,22 @@ static void __of_probe(struct device_node *node)
__of_probe(n);
}
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;
@ -991,6 +1000,7 @@ int of_probe(void)
of_chosen = of_find_node_by_path(root_node, "/chosen");
of_property_read_string(root_node, "model", &of_model);
__of_parse_phandles(root_node);
__of_probe(root_node);
return 0;