mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-10 23:24:38 +00:00
dm: device: fail uclass_find_first_device() if list_empty
While uclass_find_device() fails with -ENODEV in case of list_empty strangely uclass_find_first_device() returns 0. Fix uclass_find_first_device() to also fail with -ENODEV instead. Signed-off-by: Marcel Ziswiler <marcel.ziswiler@toradex.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
a765adc08f
commit
f388564965
2 changed files with 5 additions and 1 deletions
|
@ -225,7 +225,7 @@ int uclass_find_first_device(enum uclass_id id, struct udevice **devp)
|
|||
if (ret)
|
||||
return ret;
|
||||
if (list_empty(&uc->dev_head))
|
||||
return 0;
|
||||
return -ENODEV;
|
||||
|
||||
*devp = list_first_entry(&uc->dev_head, struct udevice, uclass_node);
|
||||
|
||||
|
|
|
@ -749,6 +749,10 @@ static int dm_test_uclass_devices_find(struct unit_test_state *uts)
|
|||
ut_assert(dev);
|
||||
}
|
||||
|
||||
ret = uclass_find_first_device(UCLASS_TEST_DUMMY, &dev);
|
||||
ut_assert(ret == -ENODEV);
|
||||
ut_assert(!dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
DM_TEST(dm_test_uclass_devices_find, DM_TESTF_SCAN_PDATA);
|
||||
|
|
Loading…
Reference in a new issue