From 95ce385a4ad0bb0d0a20f68b2a1f2451584bf3ff Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 23 Apr 2017 20:10:45 -0600 Subject: dm: core: Add uclass_first/next_device_check() Sometimes it is useful to iterate through all devices in a uclass and skip over those which do not work correctly (e.g fail to probe). Add two new functions to provide this feature. The caller must check the return value each time to make sure that the device is valid. But the device pointer is always returned. Signed-off-by: Simon Glass --- include/dm/uclass.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'include/dm/uclass.h') diff --git a/include/dm/uclass.h b/include/dm/uclass.h index 4dcd883ac5..18188497c2 100644 --- a/include/dm/uclass.h +++ b/include/dm/uclass.h @@ -278,6 +278,37 @@ int uclass_first_device_err(enum uclass_id id, struct udevice **devp); */ int uclass_next_device(struct udevice **devp); +/** + * uclass_first_device() - Get the first device in a uclass + * + * The device returned is probed if necessary, and ready for use + * + * This function is useful to start iterating through a list of devices which + * are functioning correctly and can be probed. + * + * @id: Uclass ID to look up + * @devp: Returns pointer to the first device in that uclass, or NULL if there + * is no first device + * @return 0 if OK (found or not found), other -ve on error. If an error occurs + * it is still possible to move to the next device. + */ +int uclass_first_device_check(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 + * + * This function is useful to start iterating through a list of devices which + * are functioning correctly and can be probed. + * + * @devp: On entry, pointer to device to lookup. On exit, returns pointer + * to the next device in the uclass if any + * @return 0 if OK (found or not found), other -ve on error. If an error occurs + * it is still possible to move to the next device. + */ +int uclass_next_device_check(struct udevice **devp); + /** * uclass_resolve_seq() - Resolve a device's sequence number * -- cgit