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: 1243870 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=socionext.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=nifty.com header.i=@nifty.com header.a=rsa-sha256 header.s=dec2015msa header.b=XRSJtr57; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48RVCC0lyrz9sPk for ; Tue, 25 Feb 2020 17:58:46 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6247681281; Tue, 25 Feb 2020 07:58:43 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=socionext.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=nifty.com header.i=@nifty.com header.b="XRSJtr57"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 84CB08129E; Tue, 25 Feb 2020 07:58:41 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from conuserg-08.nifty.com (conuserg-08.nifty.com [210.131.2.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 80013801A0 for ; Tue, 25 Feb 2020 07:58:35 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=socionext.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=yamada.masahiro@socionext.com Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-08.nifty.com with ESMTP id 01P6w5u5010361; Tue, 25 Feb 2020 15:58:05 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com 01P6w5u5010361 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1582613885; bh=QXdj0oAPZJR3GAoxrErDne9QuCT0npCMGB1UNLTXxNA=; h=From:To:Cc:Subject:Date:From; b=XRSJtr57rSjD75VVOxHLZa7IX5JU+h3OULo5xkxKblPGku2klxYZvmfvBjRAfobn2 rMLyGVc9r8xTkNOPqDaqjEuc+bPkdUk3h65M3Qw3V5n+ZV5nSmf03jxBxCkiFUczC9 2cIEUU1aytjV3kwhPEHkOvL5aSWGxlsfcsa3vmqsOYGgt3iT8wNVsbPdZGV951vn2P AaceTwup7qy9M/APqA76Nav6gnIYmTECqFkceIv4PmjPObheN/9G9Vo02Zj0dOP/8/ eTPkwb9Y8XLR1UX7XkF8zHoTSmH/XwXVbp3myvwc2K/9TNoVFOopTBZDssVxSrwLP/ da9sbjWOJ/aLg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Cc: Masahiro Yamada , Simon Glass Subject: [PATCH] dm: make uclass_find_first_device() return error when no defice is found Date: Tue, 25 Feb 2020 15:58:03 +0900 Message-Id: <20200225065803.30275-1-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean 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);