summaryrefslogtreecommitdiff
path: root/include/dm/uclass.h
diff options
context:
space:
mode:
authorPatrice Chotard <patrice.chotard@st.com>2018-10-24 14:10:16 +0200
committerTom Rini <trini@konsulko.com>2018-11-16 16:51:55 -0500
commit37b596ac5c5f7ac405602af2577405b1f7d38cce (patch)
treed3c8d2d796e3c3c301462e08b3cbb1a79cbe5294 /include/dm/uclass.h
parentf6abd5389ceab5fce185126c2364a324465fafbe (diff)
dm: uclass: Add uclass_foreach_dev_probe
Add uclass_foreach_dev_probe() which iterates through devices of a given uclass. Devices are probed if necessary and are ready to use. Signed-off-by: Patrice Chotard <patrice.chotard@st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/dm/uclass.h')
-rw-r--r--include/dm/uclass.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/dm/uclass.h b/include/dm/uclass.h
index 93f761c96e..1bc62d523e 100644
--- a/include/dm/uclass.h
+++ b/include/dm/uclass.h
@@ -393,4 +393,20 @@ int uclass_resolve_seq(struct udevice *dev);
#define uclass_foreach_dev_safe(pos, next, uc) \
list_for_each_entry_safe(pos, next, &uc->dev_head, uclass_node)
+/**
+ * uclass_foreach_dev_probe() - Helper function to iteration through devices
+ * of given uclass
+ *
+ * This creates a for() loop which works through the available devices in
+ * a uclass in order from start to end. Devices are probed if necessary,
+ * and ready for use.
+ *
+ * @id: Uclass ID
+ * @dev: struct udevice * to hold the current device. Set to NULL when there
+ * are no more devices.
+ */
+#define uclass_foreach_dev_probe(id, dev) \
+ for (int _ret = uclass_first_device_err(id, &dev); !_ret && dev; \
+ _ret = uclass_next_device_err(&dev))
+
#endif