summaryrefslogtreecommitdiff
path: root/drivers/core
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2017-04-24 02:10:45 (GMT)
committerSimon Glass <sjg@chromium.org>2017-07-11 16:08:19 (GMT)
commit95ce385a4ad0bb0d0a20f68b2a1f2451584bf3ff (patch)
tree29547f9066718ebdd0ab3abbaf6eb9f189d62cda /drivers/core
parent9856157259f4ab55e3d99c9aacc85f08797c8579 (diff)
downloadu-boot-fsl-qoriq-95ce385a4ad0bb0d0a20f68b2a1f2451584bf3ff.tar.xz
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 <sjg@chromium.org>
Diffstat (limited to 'drivers/core')
-rw-r--r--drivers/core/uclass.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index 97500f4..f5e4067 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -492,6 +492,33 @@ int uclass_next_device(struct udevice **devp)
return uclass_get_device_tail(dev, ret, devp);
}
+int uclass_first_device_check(enum uclass_id id, struct udevice **devp)
+{
+ int ret;
+
+ *devp = NULL;
+ ret = uclass_find_first_device(id, devp);
+ if (ret)
+ return ret;
+ if (!*devp)
+ return 0;
+
+ return device_probe(*devp);
+}
+
+int uclass_next_device_check(struct udevice **devp)
+{
+ int ret;
+
+ ret = uclass_find_next_device(devp);
+ if (ret)
+ return ret;
+ if (!*devp)
+ return 0;
+
+ return device_probe(*devp);
+}
+
int uclass_bind_device(struct udevice *dev)
{
struct uclass *uc;