From: Simon Glass Date: Tue, 11 Nov 2014 17:46:19 +0000 (-0700) Subject: dm: core: Add functions to find parent and OF data X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=479728cb0c752a121e0fd84c6c6d74e93e086905;p=u-boot.git dm: core: Add functions to find parent and OF data Add dev_get_parent() as a convenience to obtain the parent of a device. Signed-off-by: Simon Glass Reviewed-by: Tom Rini Acked-by: Heiko Schocher --- diff --git a/drivers/core/device.c b/drivers/core/device.c index 81ddecade2..6793e1c4f9 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -381,6 +381,11 @@ int device_find_next_child(struct udevice **devp) return 0; } +struct udevice *dev_get_parent(struct udevice *child) +{ + return child->parent; +} + ulong dev_get_of_data(struct udevice *dev) { return dev->of_id->data; diff --git a/include/dm/device.h b/include/dm/device.h index 287504cb27..13598a15b6 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -207,6 +207,14 @@ void *dev_get_parentdata(struct udevice *dev); */ void *dev_get_priv(struct udevice *dev); +/** + * struct dev_get_parent() - Get the parent of a device + * + * @child: Child to check + * @return parent of child, or NULL if this is the root device + */ +struct udevice *dev_get_parent(struct udevice *child); + /** * dev_get_of_data() - get the device tree data used to bind a device *