summaryrefslogtreecommitdiff
path: root/include/dm/uclass.h
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2018-11-17 08:19:40 -0500
committerTom Rini <trini@konsulko.com>2018-11-17 08:19:40 -0500
commit0c4b382f9041f9f2f00246c8a0ece90dae5451be (patch)
treea2307a0658de178c47d7a063c169347e60e1810c /include/dm/uclass.h
parent1d6edcbfed2af33c748f2beb399810a0441888da (diff)
parentad890cace37d0e2d3e0f9649bdb9c320947e4bb0 (diff)
Merge branch '2018-11-16-master-imports'
- Initial bcm968580xref, am65x_evm_r5 support - lpc32xx, omap3_logic/am3517_evm updates - pinctrl command - fs_loader available for SPL
Diffstat (limited to 'include/dm/uclass.h')
-rw-r--r--include/dm/uclass.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/include/dm/uclass.h b/include/dm/uclass.h
index 4ef0d0f0c0..1bc62d523e 100644
--- a/include/dm/uclass.h
+++ b/include/dm/uclass.h
@@ -308,6 +308,18 @@ int uclass_first_device_err(enum uclass_id id, struct udevice **devp);
int uclass_next_device(struct udevice **devp);
/**
+ * uclass_next_device_err() - Get the next device in a uclass
+ *
+ * The device returned is probed if necessary, and ready for use
+ *
+ * @devp: On entry, pointer to device to lookup. On exit, returns pointer
+ * to the next device in the uclass if no error occurred, or -ENODEV if
+ * there is no next device.
+ * @return 0 if found, -ENODEV if not found, other -ve on error
+ */
+int uclass_next_device_err(struct udevice **devp);
+
+/**
* uclass_first_device_check() - Get the first device in a uclass
*
* The device returned is probed if necessary, and ready for use
@@ -381,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