summaryrefslogtreecommitdiff
path: root/include/dm
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2016-02-11 13:23:25 -0700
committerSimon Glass <sjg@chromium.org>2016-03-14 15:34:50 -0600
commitb06750501f5c0eef7fef094f13d2f2e313c60b79 (patch)
treed0dfd81b292e93e73227e015246382ac4a6f689b /include/dm
parentdf61a74e6845ec9bdcdd48d2aff5e9c2c6debeaa (diff)
downloadu-boot-imx-b06750501f5c0eef7fef094f13d2f2e313c60b79.zip
u-boot-imx-b06750501f5c0eef7fef094f13d2f2e313c60b79.tar.gz
u-boot-imx-b06750501f5c0eef7fef094f13d2f2e313c60b79.tar.bz2
dm: core: Add uclass_first_device_err() to return a valid device
A common pattern is to call uclass_first_device() and then check if it actually returns a device. Add a new function which does this, returning an error if there are no devices in that uclass. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/dm')
-rw-r--r--include/dm/uclass.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/include/dm/uclass.h b/include/dm/uclass.h
index bfbd27a..fd368b6 100644
--- a/include/dm/uclass.h
+++ b/include/dm/uclass.h
@@ -200,18 +200,29 @@ int uclass_get_device_by_phandle(enum uclass_id id, struct udevice *parent,
*
* @id: Uclass ID to look up
* @devp: Returns pointer to the first device in that uclass, or NULL if none
- * @return 0 if OK (found or not found), -1 on error
+ * @return 0 if OK (found or not found), other -ve on error
*/
int uclass_first_device(enum uclass_id id, struct udevice **devp);
/**
+ * uclass_first_device_err() - Get the first device in a uclass
+ *
+ * The device returned is probed if necessary, and ready for use
+ *
+ * @id: Uclass ID to look up
+ * @devp: Returns pointer to the first device in that uclass, or NULL if none
+ * @return 0 if found, -ENODEV if not found, other -ve on error
+ */
+int uclass_first_device_err(enum uclass_id id, struct udevice **devp);
+
+/**
* uclass_next_device() - 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 same uclass, or NULL if none
- * @return 0 if OK (found or not found), -1 on error
+ * @return 0 if OK (found or not found), other -ve on error
*/
int uclass_next_device(struct udevice **devp);