From patchwork Wed Jan 31 13:47:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Goldschmidt X-Patchwork-Id: 867932 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3zWl2N0tHBz9ryr for ; Thu, 1 Feb 2018 00:48:27 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 3E08BC21C2F; Wed, 31 Jan 2018 13:47:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id B24BFC21DE5; Wed, 31 Jan 2018 13:47:21 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 069F2C21C29; Wed, 31 Jan 2018 13:47:19 +0000 (UTC) Received: from mailout.pepperl-fuchs.com (mailout.pepperl-fuchs.com [212.21.166.229]) by lists.denx.de (Postfix) with ESMTPS id 269D3C21C2F for ; Wed, 31 Jan 2018 13:47:19 +0000 (UTC) Received: from PFDE-CAS2.EU.P-F.BIZ (pfde-cas2.eu.p-f.biz [172.24.5.134]) by mailout.pepperl-fuchs.com (Postfix) with ESMTP id 03F8C81B23; Wed, 31 Jan 2018 14:47:19 +0100 (CET) Received: from localhost.localdomain (172.24.114.233) by PFDE-CAS2.EU.P-F.BIZ (172.24.5.134) with Microsoft SMTP Server (TLS) id 14.3.301.0; Wed, 31 Jan 2018 14:47:18 +0100 From: Simon Goldschmidt To: Date: Wed, 31 Jan 2018 14:47:10 +0100 Message-ID: <20180131134713.11566-2-sgoldschmidt@de.pepperl-fuchs.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180131134713.11566-1-sgoldschmidt@de.pepperl-fuchs.com> References: <20180131134713.11566-1-sgoldschmidt@de.pepperl-fuchs.com> MIME-Version: 1.0 X-Originating-IP: [172.24.114.233] X-EXCLAIMER-MD-CONFIG: 1e262833-c6b8-4d86-a546-40bddc43f2e2 Cc: Tom Rini , Maxime Ripard Subject: [U-Boot] [PATCH v2 1/4] env: make env_import(_redund) return 0 on success, not 1 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" env_import (and env_import_redund) currently return 1 on success and 0 on error. However, they are only used from functions returning 0 on success or a negative value on error. Let's clean this up by making env_import and env_import_redund return 0 on success and -EIO on error (as was the case for all users before). Users that cared for the return value are also updated. Funny enough, this only affects onenand.c and sf.c Signed-off-by: Simon Goldschmidt Acked-by: Maxime Ripard --- env/common.c | 8 ++++---- env/onenand.c | 4 ++-- env/sf.c | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/env/common.c b/env/common.c index c633502d68..363ba6fead 100644 --- a/env/common.c +++ b/env/common.c @@ -118,21 +118,21 @@ int env_import(const char *buf, int check) if (crc32(0, ep->data, ENV_SIZE) != crc) { set_default_env("!bad CRC"); - return 0; + return -EIO; } } if (himport_r(&env_htab, (char *)ep->data, ENV_SIZE, '\0', 0, 0, 0, NULL)) { gd->flags |= GD_FLG_ENV_READY; - return 1; + return 0; } pr_err("Cannot import environment: errno = %d\n", errno); set_default_env("!import failed"); - return 0; + return -EIO; } #ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT @@ -153,7 +153,7 @@ int env_import_redund(const char *buf1, const char *buf2) if (!crc1_ok && !crc2_ok) { set_default_env("!bad CRC"); - return 0; + return -EIO; } else if (crc1_ok && !crc2_ok) { gd->env_valid = ENV_VALID; } else if (!crc1_ok && crc2_ok) { diff --git a/env/onenand.c b/env/onenand.c index 2e3045c5f5..10a8cccbe8 100644 --- a/env/onenand.c +++ b/env/onenand.c @@ -57,10 +57,10 @@ static int env_onenand_load(void) #endif /* !ENV_IS_EMBEDDED */ rc = env_import(buf, 1); - if (rc) + if (!rc) gd->env_valid = ENV_VALID; - return rc ? 0 : -EIO; + return rc; } static int env_onenand_save(void) diff --git a/env/sf.c b/env/sf.c index a2e4c93631..3dc54410df 100644 --- a/env/sf.c +++ b/env/sf.c @@ -236,7 +236,7 @@ static int env_sf_load(void) ep = tmp_env2; ret = env_import((char *)ep, 0); - if (!ret) { + if (ret) { pr_err("Cannot import environment: errno = %d\n", errno); set_default_env("!env_import failed"); } @@ -336,7 +336,7 @@ static int env_sf_load(void) } ret = env_import(buf, 1); - if (ret) + if (!ret) gd->env_valid = ENV_VALID; err_read: