Message ID | 1540383023-1807-4-git-send-email-patrice.chotard@st.com |
---|---|
State | Accepted |
Commit | f6abd5389ceab5fce185126c2364a324465fafbe |
Delegated to: | Tom Rini |
Headers | show |
Series | Add pinmux command | expand |
On 24 October 2018 at 06:10, Patrice Chotard <patrice.chotard@st.com> wrote: > 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> > --- > > Changes in v4: None > Changes in v3: None > Changes in v2: None > > drivers/core/uclass.c | 13 +++++++++++++ > include/dm/uclass.h | 12 ++++++++++++ > 2 files changed, 25 insertions(+) Reviewed-by: Simon Glass <sjg@chromium.org> We probably should have something that calls it for testing purposes, but I suspect that comes in a future patch.
On Wed, Oct 24, 2018 at 02:10:15PM +0200, Patrice Chotard wrote: > 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> Applied to u-boot/master, thanks!
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c index 3113d6a56ba3..a4452bd9b313 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 eebf2d5614c4..39d0fdb540e9 100644 --- a/include/dm/uclass.h +++ b/include/dm/uclass.h @@ -306,6 +306,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
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> --- Changes in v4: None Changes in v3: None Changes in v2: None drivers/core/uclass.c | 13 +++++++++++++ include/dm/uclass.h | 12 ++++++++++++ 2 files changed, 25 insertions(+)