[U-Boot] [PATCH v2 03/17] dm: core: Add functions to find parent and OF data

Masahiro Yamada yamada.m at jp.panasonic.com
Wed Nov 19 09:27:24 CET 2014


On Tue, 11 Nov 2014 10:46:19 -0700
Simon Glass <sjg at chromium.org> wrote:

> Add dev_get_parent() as a convenience to obtain the parent of a device.
> 
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
> 
> Changes in v2: None
> 
>  drivers/core/device.c | 5 +++++
>  include/dm/device.h   | 8 ++++++++
>  2 files changed, 13 insertions(+)
> 
> diff --git a/drivers/core/device.c b/drivers/core/device.c
> index 0d84776..76b29fd 100644
> --- a/drivers/core/device.c
> +++ b/drivers/core/device.c
> @@ -549,6 +549,11 @@ int device_find_next_child(struct udevice **devp)
>  	return 0;
>  }
>  
> +struct udevice *dev_get_parent(struct udevice *child)
> +{
> +	return child->parent;
> +}
> +

Why do you want this?  "dev_get_parent(dev)" is longer than "dev->parent".

I am not sure if this helper function is useful,
but if really necessary, static inline or macro ??


Perhaps,  "struct udevice *dev" rather than "struct udevice *child"
for consistency?




Best Regards
Masahiro Yamada



More information about the U-Boot mailing list