From patchwork Fri Sep 11 16:32:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 516907 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 2288614012C for ; Sat, 12 Sep 2015 02:33:28 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=t++h8i29; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5024F4B723; Fri, 11 Sep 2015 18:33:25 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LLzXrRnBEBwT; Fri, 11 Sep 2015 18:33:25 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9FC424B72D; Fri, 11 Sep 2015 18:33:22 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 77EAF4B699 for ; Fri, 11 Sep 2015 18:33:17 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id x1h1vsLxN-cC for ; Fri, 11 Sep 2015 18:33:17 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-yk0-f169.google.com (mail-yk0-f169.google.com [209.85.160.169]) by theia.denx.de (Postfix) with ESMTPS id 1DFE44B694 for ; Fri, 11 Sep 2015 18:33:13 +0200 (CEST) Received: by ykei199 with SMTP id i199so96637889yke.0 for ; Fri, 11 Sep 2015 09:33:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IGv+T/nrut73rR2cHxwCLLn5+6HlAoKVzfSW4iFAX60=; b=t++h8i29eezhjOggh/rqBpjPAmBZHKRcTN4IAivIDwxHsVyBN7C2gIS/8wDanyXM3w aefptt0SObQAg4h7jcyorcbZJu8BwAIWhuyQozWktKBEPJqB+2ppTasuGNFuX8Uvws3i sjPIQn1L0nIXBpVmvUWrMyxQxRQXfVL+ZNRQr5EsKsCAwea5debjY0PyCHhHL6QBgFQ3 CWJlFFl1eulut6g4+PHYlmLgS3ixvHM6ZuH4beDL/QP4QlDtW3irGLYeNCvQiERoxD+P fNLgdTo8quuKBsP6kJEmLlE29jpTU+oU/+QIKwJ9Ra8xgjKdhLrBcT/thN4xRJjdVkXG 1Yxg== X-Received: by 10.13.213.17 with SMTP id x17mr52270638ywd.164.1441989192278; Fri, 11 Sep 2015 09:33:12 -0700 (PDT) Received: from localhost.localdomain ([179.159.191.85]) by smtp.gmail.com with ESMTPSA id w186sm687486ywf.18.2015.09.11.09.33.10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 11 Sep 2015 09:33:11 -0700 (PDT) From: Fabio Estevam To: sbabic@denx.de Date: Fri, 11 Sep 2015 13:32:50 -0300 Message-Id: <1441989170-25302-2-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1441989170-25302-1-git-send-email-festevam@gmail.com> References: <1441989170-25302-1-git-send-email-festevam@gmail.com> Cc: Fabio Estevam , u-boot@lists.denx.de Subject: [U-Boot] [PATCH 2/2] udoo: Fix the error handling in board_eth_init() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Fabio Estevam We should not return 0 on failure, so return a negative error code instead. Also centralize the error path so that is easier to follow. Signed-off-by: Fabio Estevam --- board/udoo/udoo.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/board/udoo/udoo.c b/board/udoo/udoo.c index a8bd90a..a574a2f 100644 --- a/board/udoo/udoo.c +++ b/board/udoo/udoo.c @@ -191,23 +191,26 @@ int board_eth_init(bd_t *bis) #ifdef CONFIG_FEC_MXC bus = fec_get_miibus(base, -1); if (!bus) - return 0; + return -EINVAL; /* scan phy 4,5,6,7 */ phydev = phy_find_by_mask(bus, (0xf << 4), PHY_INTERFACE_MODE_RGMII); if (!phydev) { - free(bus); - return 0; + ret = -EINVAL; + goto free_bus; } printf("using phy at %d\n", phydev->addr); ret = fec_probe(bis, -1, base, bus, phydev); - if (ret) { - printf("FEC MXC: %s:failed\n", __func__); - free(phydev); - free(bus); - } + if (ret) + goto free_phydev; #endif return 0; + +free_phydev: + free(phydev); +free_bus: + free(bus); + return ret; } int board_mmc_init(bd_t *bis)