summaryrefslogtreecommitdiff
path: root/drivers/core
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2015-03-25 12:21:57 -0600
committerSimon Glass <sjg@chromium.org>2015-04-18 11:11:19 -0600
commitc5785673bc6f4b8f2a4974979710a2c5c15eb063 (patch)
tree664a8e740827abdd48b4b3959155052c2842d35b /drivers/core
parent206d4d2b4b30889678bb6b064002013a427b1501 (diff)
dm: core: Add device children and sibling functions
Add some utility functions to check for children and for the last sibling in a device's parent. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Marek Vasut <marex@denx.de>
Diffstat (limited to 'drivers/core')
-rw-r--r--drivers/core/device.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/core/device.c b/drivers/core/device.c
index b7ed21c003..ccaa99ca63 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -490,3 +490,31 @@ fdt_addr_t dev_get_addr(struct udevice *dev)
return FDT_ADDR_T_NONE;
}
#endif
+
+bool device_has_children(struct udevice *dev)
+{
+ return !list_empty(&dev->child_head);
+}
+
+bool device_has_active_children(struct udevice *dev)
+{
+ struct udevice *child;
+
+ for (device_find_first_child(dev, &child);
+ child;
+ device_find_next_child(&child)) {
+ if (device_active(child))
+ return true;
+ }
+
+ return false;
+}
+
+bool device_is_last_sibling(struct udevice *dev)
+{
+ struct udevice *parent = dev->parent;
+
+ if (!parent)
+ return false;
+ return list_is_last(&dev->sibling_node, &parent->child_head);
+}