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

Simon Glass sjg at chromium.org
Wed Nov 19 10:37:37 CET 2014


Hi Masahiro,

On 19 November 2014 08:27, Masahiro Yamada <yamada.m at jp.panasonic.com> wrote:
>
> 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 ??

See my comment on the other patch.

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

Maybe, but I feel this is clearer even if it is inconsistent. I try to
use 'bus' instead of dev when there is a bus too, to help with
understanding.

Regards,
Simon


More information about the U-Boot mailing list