
Hi Michal,
On Sun, 25 Sept 2022 at 02:28, Michal Suchanek msuchanek@suse.de wrote:
The _err variant iterators use the simple iterators without suffix as basis.
However, there is no user that uclass_next_device_err for iteration, many users of uclass_first_device_err use it to get the first and (assumed) only device of an uclass, and a couple that use uclass_next_device_err to get the device following a known device in the uclass list.
While there are some truly singleton device classes in which more than one device cannot exist these are quite rare, and most classes can have multiple devices even if it is not the case on the SoC's EVB.
In a later patch the simple iterators will be updated to not stop on error and return next device instead. With this in many cases the code that expects the first device or an error if it fails to probe may get the next device instead. Use the _check iterators as the basis of _err iterators to preserve the old behavior.
This is problematic for eth_get_dev: it relies on the broken behavior that returns an error but not the device on which the error happened which gives the caller no reasonable way to report or handle the error. With this change the device is returned but eth_get_dev stores the returned device pointer directly in a global state without checking the return value. Unset the pointer again in the error case.
Signed-off-by: Michal Suchanek msuchanek@suse.de
drivers/core/uclass.c | 28 ++++++++++++++-------------- include/dm/uclass.h | 22 +++++++++++----------- net/eth-uclass.c | 2 ++
Reviewed-by: Simon Glass sjg@chromium.org
Better to split out the net: patch.
3 files changed, 27 insertions(+), 25 deletions(-)
Regards, Simon