diff --git a/drivers/of/base.c b/drivers/of/base.c index f363cc1..e9f0883 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -356,6 +356,27 @@ } EXPORT_SYMBOL(of_node_create_phandle); +int of_set_property_to_child_phandle(struct device_node *node, char *prop_name) +{ + int ret; + phandle p; + + /* Check if property exist */ + if (!of_get_property(of_get_parent(node), prop_name, NULL)) + return -EINVAL; + + /* Create or get existing phandle of child node */ + p = of_node_create_phandle(node); + p = cpu_to_be32(p); + + node = of_get_parent(node); + + ret = of_set_property(node, prop_name, &p, sizeof(p), 0); + + return ret; +} +EXPORT_SYMBOL(of_set_property_to_child_phandle); + /* * Find a property with a given name for a given node * and return the value. diff --git a/include/of.h b/include/of.h index decf151..29694a9 100644 --- a/include/of.h +++ b/include/of.h @@ -714,6 +714,7 @@ phandle of_get_tree_max_phandle(struct device_node *root); phandle of_node_create_phandle(struct device_node *node); +int of_set_property_to_child_phandle(struct device_node *node, char *prop_name); struct device_node *of_find_node_by_alias(struct device_node *root, const char *alias); struct device_node *of_find_node_by_path_or_alias(struct device_node *root,