summaryrefslogtreecommitdiffstats
path: root/include/dm/device.h
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2015-11-08 23:47:52 -0700
committerSimon Glass <sjg@chromium.org>2015-11-19 20:27:51 -0700
commit7aeac5bc8c5903b8d27188a21b39f0b2c4bd13c1 (patch)
treed2bc124ba0ef8028c5e183e8112b317b30621f43 /include/dm/device.h
parent45bfa47e123cdb0df8e273e3f0c84907c7394f6a (diff)
downloadblackbird-obmc-uboot-7aeac5bc8c5903b8d27188a21b39f0b2c4bd13c1.tar.gz
blackbird-obmc-uboot-7aeac5bc8c5903b8d27188a21b39f0b2c4bd13c1.zip
dm: core: Add safe device iteration macros
Add iteration macros which support unbinding a device within the loop. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/dm/device.h')
-rw-r--r--include/dm/device.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/dm/device.h b/include/dm/device.h
index 28ba4ca404..7fb99356be 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -509,6 +509,18 @@ static inline bool device_is_on_pci_bus(struct udevice *dev)
return device_get_uclass_id(dev->parent) == UCLASS_PCI;
}
+/**
+ * device_foreach_child_safe() - iterate through child devices safely
+ *
+ * This allows the @pos child to be removed in the loop if required.
+ *
+ * @pos: struct udevice * for the current device
+ * @next: struct udevice * for the next device
+ * @parent: parent device to scan
+ */
+#define device_foreach_child_safe(pos, next, parent) \
+ list_for_each_entry_safe(pos, next, &parent->child_head, sibling_node)
+
/* device resource management */
typedef void (*dr_release_t)(struct udevice *dev, void *res);
typedef int (*dr_match_t)(struct udevice *dev, void *res, void *match_data);
OpenPOWER on IntegriCloud