diff options
-rw-r--r-- | drivers/core/uclass.c | 13 | ||||
-rw-r--r-- | include/dm/uclass.h | 12 |
2 files changed, 25 insertions, 0 deletions
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c index 6cfcde8918..d9c5719a87 100644 --- a/drivers/core/uclass.c +++ b/drivers/core/uclass.c @@ -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; diff --git a/include/dm/uclass.h b/include/dm/uclass.h index 4ef0d0f0c0..93f761c96e 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 |