]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: uclass: Add uclass_next_device_err() to return a valid device
authorPatrice Chotard <patrice.chotard@st.com>
Wed, 24 Oct 2018 12:10:15 +0000 (14:10 +0200)
committerTom Rini <trini@konsulko.com>
Fri, 16 Nov 2018 21:51:55 +0000 (16:51 -0500)
Similarly to uclass_first_device_err(), add uclass_next_device_err()
which returns an error if there are no next devices in that uclass.

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
drivers/core/uclass.c
include/dm/uclass.h

index 6cfcde8918c4dc4dfba1e722e82ccb1d9ec6b16b..d9c5719a878d75abdd76b51a81970936693e38b7 100644 (file)
@@ -562,6 +562,19 @@ int uclass_next_device(struct udevice **devp)
        return uclass_get_device_tail(dev, ret, devp);
 }
 
+int uclass_next_device_err(struct udevice **devp)
+{
+       int ret;
+
+       ret = uclass_next_device(devp);
+       if (ret)
+               return ret;
+       else if (!*devp)
+               return -ENODEV;
+
+       return 0;
+}
+
 int uclass_first_device_check(enum uclass_id id, struct udevice **devp)
 {
        int ret;
index 4ef0d0f0c01285cb314473b9a883cd525deafc86..93f761c96eb80f2e13d21c991a4bef5432ecc311 100644 (file)
@@ -307,6 +307,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
  *