From patchwork Tue Feb 25 06:58:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 236788 List-Id: U-Boot discussion From: yamada.masahiro at socionext.com (Masahiro Yamada) Date: Tue, 25 Feb 2020 15:58:03 +0900 Subject: [PATCH] dm: make uclass_find_first_device() return error when no defice is found Message-ID: <20200225065803.30275-1-yamada.masahiro@socionext.com> uclass_find_first_device() succeeds even if it cannot find any device. So, the caller must check the return code and also *devp is not NULL. Returning -ENODEV will be sensible in this case. Signed-off-by: Masahiro Yamada --- If this patch is acceptable, I want to fold this into my pull request because it need it for my another patch: http://patchwork.ozlabs.org/patch/1238000/ drivers/core/uclass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c index 58b19a421091..3580974f3b85 100644 --- a/drivers/core/uclass.c +++ b/drivers/core/uclass.c @@ -227,7 +227,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);