From mboxrd@z Thu Jan 1 00:00:00 1970 From: Simon Glass Date: Sun, 12 Oct 2014 23:39:28 -0600 Subject: [U-Boot] [RFC PATCH 02/12] dm: core: Add functions to find parent and OF data In-Reply-To: <1413178778-30846-1-git-send-email-sjg@chromium.org> References: <1413178778-30846-1-git-send-email-sjg@chromium.org> Message-ID: <1413178778-30846-3-git-send-email-sjg@chromium.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Add dev_get_parent() as a convenience to obtain the parent of a device. Signed-off-by: Simon Glass --- 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; +} + 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 a712156..e8b7fcf 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -202,6 +202,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 * * When a device is bound using a device tree node, it matches a -- 2.1.0.rc2.206.gedb03e5