[PATCH 13/22] OF: base: import parent/child functions from Linux OF API

Sascha Hauer s.hauer at pengutronix.de
Tue Jun 18 16:18:00 EDT 2013


On Tue, Jun 18, 2013 at 07:29:58PM +0200, Sebastian Hesselbarth wrote:
> This imports of_get_parent, of_get_next_child, of_get_next_available_child,
> and of_get_child_by_name and corresponding helpers from Linux OF API.
> 
> Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth at gmail.com>
> ---
> Cc: barebox at lists.infradead.org
> ---
>  drivers/of/base.c |   78 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  include/of.h      |   49 +++++++++++++++++++++++++++++++++
>  2 files changed, 127 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 148f832..17364ea 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -862,6 +862,84 @@ int of_device_is_available(const struct device_node *device)
>  }
>  EXPORT_SYMBOL(of_device_is_available);
>  
> +/**
> + *	of_get_parent - Get a node's parent if any
> + *	@node:	Node to get parent
> + *
> + *	Returns a pointer to the parent node or NULL if already at root.
> + */
> +struct device_node *of_get_parent(const struct device_node *node)
> +{
> +	if (!node)
> +		return NULL;
> +
> +	return (node == root_node) ? NULL : node->parent;

parent should be NULL for the root_node, so it should be safe to remove
this additional check. This is also in the sense of making multiple
devicetrees possible.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list