From patchwork Tue Nov 28 10:24:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 119819 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1514947qgn; Tue, 28 Nov 2017 02:26:22 -0800 (PST) X-Google-Smtp-Source: AGs4zMY4dJdTiysvCj2yKthdXOZvcqFlVhYWNyi3Scb0O1SReieTL20QgXw9inCWpqdJUwy4BOJf X-Received: by 10.80.134.135 with SMTP id r7mr1946716eda.241.1511864782840; Tue, 28 Nov 2017 02:26:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511864782; cv=none; d=google.com; s=arc-20160816; b=LcC4kGNVIGkV+hgb7X+pTlcGKYzBbnBzx/ASOP0KCWj1AZIJmHJvpZLeLlTW1BI0kr 70CyZLP0DDhAkG1LKX8rsuc4aUAB4hiapwi/m9E+H8+KJjdov8GXKTnbYzIwiJD8zkso 9TyElhv0KuK+oMu4ap2FZmrSO26L+RfFcFxqQTqtaB+hFyjxhHPRWbb3ZS/7KfFvtAZv t6sEAJlawVPvP2fqIhoDZ1x43c1CYAN1lTyv9IScyuNUpA53F4Bh8RFeOeIHHXyd5Gy4 gyXkwBz3BdCqvCkpsqBm7rYz/VsoMlLbiUN4YQyRijfmAbteGgPaQVuqugm0LpCOpagx 7Rsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:references :in-reply-to:message-id:date:to:from:arc-authentication-results; bh=Xcfwaf8OShZUgWUmXzjDnnLD4HF5b61/4d5W5T4o9yk=; b=Mui2Y2Ig8FTbea0rDywQ/yP2IY8sQIl6lxBxRdZxL/Lhkxxa87/Qv8MBQABzZelhWN 3l/VOwHwV2C4V2sdGe6ViG1614l/FhRp6pJmD6HZp+OBxg+OGywoEvfK7syyYNNCsDAn iOlTPzOQr48BIb3xBdKPKHY3hQLlaIvTQqtz/LPyFgFpgJNvN7/BHgn8gtp5ER0iWSA1 Tftzy2JgujNri6sAm9jnOCevj9JDSXEcx9rDTURN9Srx72mVIQwvxO2CYtP7wdlXTZjo bBa47La/ccSVBdanIWIobE5t3j7BReOtqzckxPEpTJfkY61EZhxF6tdnhz7DJZEXYNLW KxjA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id g8si3151574edb.338.2017.11.28.02.26.22; Tue, 28 Nov 2017 02:26:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 61B47C21E40; Tue, 28 Nov 2017 10:25:57 +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=0.0 required=5.0 tests=none 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 8A664C21E26; Tue, 28 Nov 2017 10:24:57 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 9C59DC21D6A; Tue, 28 Nov 2017 10:24:53 +0000 (UTC) Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id 52321C21D79 for ; Tue, 28 Nov 2017 10:24:53 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id A256520746; Tue, 28 Nov 2017 11:24:52 +0100 (CET) Received: from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 76ECC20380; Tue, 28 Nov 2017 11:24:52 +0100 (CET) From: Maxime Ripard To: Tom Rini Date: Tue, 28 Nov 2017 11:24:36 +0100 Message-Id: <7e3a78f964aaf9c1c4cabd0b2723b429cab73cdc.1511864667.git-series.maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: References: In-Reply-To: References: Cc: Thomas Petazzoni , u-boot@lists.denx.de, Andre Przywara , agraf@suse.de, Maxime Ripard , Jagan Teki Subject: [U-Boot] [PATCH 01/14] cmd: nvedit: Get rid of the env lookup 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The nvedit command is the only user of env_driver_lookup_default outside of the environment code itself, and it uses it only to print the environment it's about to save to during env save. As we're about to rework the environment to be able to handle multiple environment sources, we might not have an idea of what environment backend is going to be used before trying (and possibly failing for some). Therefore, it makes sense to remove that message and move it to the env_save function itself. As a side effect, we also can get rid of the call to env_driver_lookup_default that is also about to get refactored. Reviewed-by: Lukasz Majewski Signed-off-by: Maxime Ripard Reviewed-by: Andre Przywara Reviewed-by: Simon Glass --- cmd/nvedit.c | 4 ---- env/env.c | 4 +++- include/environment.h | 7 ------- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/cmd/nvedit.c b/cmd/nvedit.c index 4e79d03856fe..a690d743cd46 100644 --- a/cmd/nvedit.c +++ b/cmd/nvedit.c @@ -708,10 +708,6 @@ ulong env_get_ulong(const char *name, int base, ulong default_val) static int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { - struct env_driver *env = env_driver_lookup_default(); - - printf("Saving Environment to %s...\n", env->name); - return env_save() ? 1 : 0; } diff --git a/env/env.c b/env/env.c index 76a5608628fc..094538ff5b62 100644 --- a/env/env.c +++ b/env/env.c @@ -52,7 +52,7 @@ static enum env_location env_get_default_location(void) return ENVL_UNKNOWN; } -struct env_driver *env_driver_lookup_default(void) +static struct env_driver *env_driver_lookup_default(void) { enum env_location loc = env_get_default_location(); struct env_driver *drv; @@ -115,6 +115,8 @@ int env_save(void) return -ENODEV; if (!drv->save) return -ENOSYS; + + printf("Saving Environment to %s...\n", drv->name); ret = drv->save(); if (ret) { debug("%s: Environment failed to save (err=%d)\n", __func__, diff --git a/include/environment.h b/include/environment.h index 7b9821638960..226e3ef2d23a 100644 --- a/include/environment.h +++ b/include/environment.h @@ -303,13 +303,6 @@ int env_import_redund(const char *buf1, const char *buf2); #endif /** - * env_driver_lookup_default() - Look up the default environment driver - * - * @return pointer to driver, or NULL if none (which should not happen) - */ -struct env_driver *env_driver_lookup_default(void); - -/** * env_get_char() - Get a character from the early environment * * This reads from the pre-relocation environemnt From patchwork Tue Nov 28 10:24:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 119825 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2911974edl; Tue, 28 Nov 2017 02:30:49 -0800 (PST) X-Google-Smtp-Source: AGs4zMblRKXFinMHXHaIIsVX1AqlsFlHJ6ZwQ0PA3wrsELWAPHI6f8w+WMy00Q4cGtbamTbzOlUm X-Received: by 10.80.245.102 with SMTP id w35mr1938366edm.179.1511865049140; Tue, 28 Nov 2017 02:30:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511865049; cv=none; d=google.com; s=arc-20160816; b=HbCn3sy7GVsTBqaT9z8gyOt484iQRvyYpO7tiLtMtiAipzkGLGU+iy3D3KZDZ87WOm JdTmcnDu6l8EdIbuCSdZFUEGDqR2+/c+bInzogXiG0JgxqL5Z4r+9Nx5pqEsos/KRKti KZdamg2wyzub280ZXS3C+8oZ7DSZycOzhsSj8iGPZCeRGgNAFqYDxuhByyhArQ+Cl99v fWbR8FCugxAJfJ545/JMgaKfo075VivdyMlw5ClwxvPaP2NU2QkwtcIqGSf+vGTO0daA vgxST5968NEtSIWDBvFebEXRfUjax8UQM7kDsmS2HTxkp/V2zwhB67iIV6ru/+sF1UEj luZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:references :in-reply-to:message-id:date:to:from:arc-authentication-results; bh=UZ0D9OBYBFzyqHEWI+vCsFwrP2HNVjqwhmsDeZhL9qc=; b=LUCIRn9ufr0Yg8e8ynga4/sjke/qTETe4wjc65wDCP5WZAODsCRJfUm4U8cXd+OG7m XFNYOV+R6770Sk7rML5MiOQjeI0A4pZKxBqBBuuekow6o60rLLxLQTSIgXzLIkFquCRo W2/FleKhTnJpkQnli8POU32tUKxs4NbNMo8I1OWlpMCUKYAdxuXdijUSDXVHpnf2Rfaj PF9bpfW1GNNaJjn7hBb1/qk+Ru8Nj2Lap9XxtTl6cQSgLmW6zJj7pMsxvjWL4cB/E/ct qaZVpF8ApaeorfAhR+qnuXzKIXhsX7r3wruhVTJk90JgNw/v3Uf4IhYLW6if5dCajjWg wGrA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id s7si3108016edh.291.2017.11.28.02.30.48; Tue, 28 Nov 2017 02:30:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id BEF37C21E0C; Tue, 28 Nov 2017 10:26:14 +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=0.0 required=5.0 tests=none 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 E3041C21DF3; Tue, 28 Nov 2017 10:24:58 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 0D50AC21D6A; Tue, 28 Nov 2017 10:24:53 +0000 (UTC) Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id AB27EC21D79 for ; Tue, 28 Nov 2017 10:24:53 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 0B4B72074B; Tue, 28 Nov 2017 11:24:53 +0100 (CET) Received: from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id D42A620380; Tue, 28 Nov 2017 11:24:52 +0100 (CET) From: Maxime Ripard To: Tom Rini Date: Tue, 28 Nov 2017 11:24:37 +0100 Message-Id: X-Mailer: git-send-email 2.14.3 In-Reply-To: References: In-Reply-To: References: Cc: Thomas Petazzoni , u-boot@lists.denx.de, Andre Przywara , agraf@suse.de, Maxime Ripard , Jagan Teki Subject: [U-Boot] [PATCH 02/14] env: Rename env_driver_lookup_default and env_get_default_location 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The env_driver_lookup_default and env_get_default_location functions are about to get refactored to support loading from multiple environment. The name is therefore not really well suited anymore. Drop the default part to be a bit more relevant. Reviewed-by: Lukasz Majewski Signed-off-by: Maxime Ripard Reviewed-by: Andre Przywara Reviewed-by: Simon Glass --- env/env.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/env/env.c b/env/env.c index 094538ff5b62..97ada5b5a6fd 100644 --- a/env/env.c +++ b/env/env.c @@ -10,7 +10,7 @@ DECLARE_GLOBAL_DATA_PTR; -static struct env_driver *env_driver_lookup(enum env_location loc) +static struct env_driver *_env_driver_lookup(enum env_location loc) { struct env_driver *drv; const int n_ents = ll_entry_count(struct env_driver, env_driver); @@ -26,7 +26,7 @@ static struct env_driver *env_driver_lookup(enum env_location loc) return NULL; } -static enum env_location env_get_default_location(void) +static enum env_location env_get_location(void) { if IS_ENABLED(CONFIG_ENV_IS_IN_EEPROM) return ENVL_EEPROM; @@ -52,12 +52,12 @@ static enum env_location env_get_default_location(void) return ENVL_UNKNOWN; } -static struct env_driver *env_driver_lookup_default(void) +static struct env_driver *env_driver_lookup(void) { - enum env_location loc = env_get_default_location(); + enum env_location loc = env_get_location(); struct env_driver *drv; - drv = env_driver_lookup(loc); + drv = _env_driver_lookup(loc); if (!drv) { debug("%s: No environment driver for location %d\n", __func__, loc); @@ -69,7 +69,7 @@ static struct env_driver *env_driver_lookup_default(void) int env_get_char(int index) { - struct env_driver *drv = env_driver_lookup_default(); + struct env_driver *drv = env_driver_lookup(); int ret; if (gd->env_valid == ENV_INVALID) @@ -89,7 +89,7 @@ int env_get_char(int index) int env_load(void) { - struct env_driver *drv = env_driver_lookup_default(); + struct env_driver *drv = env_driver_lookup(); int ret = 0; if (!drv) @@ -108,7 +108,7 @@ int env_load(void) int env_save(void) { - struct env_driver *drv = env_driver_lookup_default(); + struct env_driver *drv = env_driver_lookup(); int ret; if (!drv) @@ -129,7 +129,7 @@ int env_save(void) int env_init(void) { - struct env_driver *drv = env_driver_lookup_default(); + struct env_driver *drv = env_driver_lookup(); int ret = -ENOENT; if (!drv) From patchwork Tue Nov 28 10:24:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 119826 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2912513edl; Tue, 28 Nov 2017 02:31:17 -0800 (PST) X-Google-Smtp-Source: AGs4zManjPc9NNQ/oqp1RPctp2kfgcI4Ny1f2L8kLAaMVm2eF+z0eWwNiUoGx4U4Ql1OjbCJVHwA X-Received: by 10.80.137.154 with SMTP id g26mr1985235edg.146.1511865077325; Tue, 28 Nov 2017 02:31:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511865077; cv=none; d=google.com; s=arc-20160816; b=tkvU7kXYZlZuCGDJXgtNCtJ8PfWAI1krPeEwjty8wt1nAKEXMHHaO4Q7Q94GqQxUqC dGyOb4rRCBdmVugnint5O5TEcZJo/es/Lo+PeKGKn2uXbIVNgcmlB+FaigQpnP9y9ldF b2Uo5dEtnnlezKGaxLEnQxKySux4drXVtOqzKILEt/jF87ux34/QR/9UtVSRm6kmPvn2 jX2o4yVhOdLqrNggkqK3IyfUmNeEb0cgiKmegioLoym1I/Hw6KMuWK+alXejFyLmf/sg 1W9ajOMjG2Gp2Ak8ab/JcNP+ObqigNXfMfQ6GL4TxVwb3BumlR2fpLrZ/eRAfHUQtHn3 MjNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:references :in-reply-to:message-id:date:to:from:arc-authentication-results; bh=1HIsyQhwQ9J/IFi2xvCKW1kx4mE/eO6NIHF/Ka4X+hk=; b=OO9XmdpdW4cI14DirpEFz9v/6VstCcusId06N1kozCWwNvfpBA5p/60sTDmMwheJlv pfFX6XZj2RYshQUys9GTA1VKVvAmybVWm2RTvzWpBm+/03Y0vCor1ELEq/Ncb3uYt97C HjPs90SgDpC5/fmotugC4AXFm2HPZX/CzV4zpkD1KWe9/tzlN+bhsPRbboi0VCVVWteY D2Ghe1eSvdBLT6JG8YMTjgUQVXgcAfP+np82tF4LPYD6avJV/8L7x+NyvK13Ep3e+r5x D7Pt6KnsBpqcZodUqttfVzM/F8841+2tVa1cVlopPtqgasauVU68WBnnYQVNFL+NrjdG KfYg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id 93si7222985ede.482.2017.11.28.02.31.17; Tue, 28 Nov 2017 02:31:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id D8E94C21E2F; Tue, 28 Nov 2017 10:26:31 +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=0.0 required=5.0 tests=none 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 66B78C21E18; Tue, 28 Nov 2017 10:25:00 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 76C3FC21DA2; Tue, 28 Nov 2017 10:24:54 +0000 (UTC) Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id 18FFBC21D79 for ; Tue, 28 Nov 2017 10:24:54 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 6D8312074D; Tue, 28 Nov 2017 11:24:53 +0100 (CET) Received: from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 416FA20380; Tue, 28 Nov 2017 11:24:53 +0100 (CET) From: Maxime Ripard To: Tom Rini Date: Tue, 28 Nov 2017 11:24:38 +0100 Message-Id: <275d9901f239926baf949612e99bae437fc1836f.1511864667.git-series.maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: References: In-Reply-To: References: Cc: Thomas Petazzoni , u-boot@lists.denx.de, Andre Przywara , agraf@suse.de, Maxime Ripard , Jagan Teki Subject: [U-Boot] [PATCH 03/14] env: Pass additional parameters to the env lookup function 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" In preparation for the multiple environment support, let's introduce two new parameters to the environment driver lookup function: the priority and operation. The operation parameter is meant to identify, obviously, the operation you might want to perform on the environment. The priority is a number passed to identify the environment priority you want to retrieve. The lowest priority parameter (0) will be the primary source. Combining the two parameters allow you to support multiple environments through different priorities, and to change those priorities between read and writes operations. This is especially useful to implement migration mechanisms where you want to always use the same environment first, be it to read or write, while the common case is more likely to use the same environment it has read from to write it to. Signed-off-by: Maxime Ripard --- env/env.c | 122 +++++++++++++++++++++++++------------------ include/environment.h | 7 ++- 2 files changed, 80 insertions(+), 49 deletions(-) diff --git a/env/env.c b/env/env.c index 97ada5b5a6fd..673bfa6ba41b 100644 --- a/env/env.c +++ b/env/env.c @@ -26,8 +26,11 @@ static struct env_driver *_env_driver_lookup(enum env_location loc) return NULL; } -static enum env_location env_get_location(void) +static enum env_location env_get_location(enum env_operation op, int prio) { + if (prio >= 1) + return ENVL_UNKNOWN; + if IS_ENABLED(CONFIG_ENV_IS_IN_EEPROM) return ENVL_EEPROM; else if IS_ENABLED(CONFIG_ENV_IS_IN_FAT) @@ -52,11 +55,14 @@ static enum env_location env_get_location(void) return ENVL_UNKNOWN; } -static struct env_driver *env_driver_lookup(void) +static struct env_driver *env_driver_lookup(enum env_operation op, int prio) { - enum env_location loc = env_get_location(); + enum env_location loc = env_get_location(op, prio); struct env_driver *drv; + if (loc == ENVL_UNKNOWN) + return NULL; + drv = _env_driver_lookup(loc); if (!drv) { debug("%s: No environment driver for location %d\n", __func__, @@ -69,83 +75,101 @@ static struct env_driver *env_driver_lookup(void) int env_get_char(int index) { - struct env_driver *drv = env_driver_lookup(); - int ret; + struct env_driver *drv; + int prio; if (gd->env_valid == ENV_INVALID) return default_environment[index]; - if (!drv) - return -ENODEV; - if (!drv->get_char) - return *(uchar *)(gd->env_addr + index); - ret = drv->get_char(index); - if (ret < 0) { - debug("%s: Environment failed to load (err=%d)\n", - __func__, ret); + + for (prio = 0; (drv = env_driver_lookup(ENVO_GET_CHAR, prio)); prio++) { + int ret; + + if (!drv->get_char) + continue; + + ret = drv->get_char(index); + if (!ret) + return 0; + + debug("%s: Environment %s failed to load (err=%d)\n", __func__, + drv->name, ret); } - return ret; + return -ENODEV; } int env_load(void) { - struct env_driver *drv = env_driver_lookup(); - int ret = 0; + struct env_driver *drv; + int prio; - if (!drv) - return -ENODEV; - if (!drv->load) - return 0; - ret = drv->load(); - if (ret) { - debug("%s: Environment failed to load (err=%d)\n", __func__, - ret); - return ret; + for (prio = 0; (drv = env_driver_lookup(ENVO_LOAD, prio)); prio++) { + int ret; + + if (!drv->load) + continue; + + ret = drv->load(); + if (!ret) + return 0; + + debug("%s: Environment %s failed to load (err=%d)\n", __func__, + drv->name, ret); } - return 0; + return -ENODEV; } int env_save(void) { - struct env_driver *drv = env_driver_lookup(); - int ret; + struct env_driver *drv; + int prio; - if (!drv) - return -ENODEV; - if (!drv->save) - return -ENOSYS; - - printf("Saving Environment to %s...\n", drv->name); - ret = drv->save(); - if (ret) { - debug("%s: Environment failed to save (err=%d)\n", __func__, - ret); - return ret; + for (prio = 0; (drv = env_driver_lookup(ENVO_SAVE, prio)); prio++) { + int ret; + + if (!drv->save) + continue; + + printf("Saving Environment to %s...\n", drv->name); + ret = drv->save(); + if (!ret) + return 0; + + debug("%s: Environment %s failed to save (err=%d)\n", __func__, + drv->name, ret); } - return 0; + return -ENODEV; } int env_init(void) { - struct env_driver *drv = env_driver_lookup(); + struct env_driver *drv; int ret = -ENOENT; + int prio; + + for (prio = 0; (drv = env_driver_lookup(ENVO_INIT, prio)); prio++) { + if (!drv->init) + continue; - if (!drv) - return -ENODEV; - if (drv->init) ret = drv->init(); + if (!ret) + return 0; + + debug("%s: Environment %s failed to init (err=%d)\n", __func__, + drv->name, ret); + } + + if (!prio) + return -ENODEV; + if (ret == -ENOENT) { gd->env_addr = (ulong)&default_environment[0]; gd->env_valid = ENV_VALID; return 0; - } else if (ret) { - debug("%s: Environment failed to init (err=%d)\n", __func__, - ret); - return ret; } - return 0; + return ret; } diff --git a/include/environment.h b/include/environment.h index 226e3ef2d23a..7fa8b98cc0db 100644 --- a/include/environment.h +++ b/include/environment.h @@ -215,6 +215,13 @@ enum env_location { ENVL_UNKNOWN, }; +enum env_operation { + ENVO_GET_CHAR, + ENVO_INIT, + ENVO_LOAD, + ENVO_SAVE, +}; + struct env_driver { const char *name; enum env_location location; From patchwork Tue Nov 28 10:24:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 119829 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2915460edl; Tue, 28 Nov 2017 02:34:23 -0800 (PST) X-Google-Smtp-Source: AGs4zMZxQQ5f+qDRmvwc7DfppdRHBJFBDffk7hLUwrj2s3mbCMQPR+jRiUmHkAGOTe6NkjGcE+6l X-Received: by 10.80.175.161 with SMTP id h30mr2027359edd.292.1511865263265; Tue, 28 Nov 2017 02:34:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511865263; cv=none; d=google.com; s=arc-20160816; b=pG/jYaZFN7jQChtk/ZJlIpRa7WFAse3TgH5frnMQ/Ty4yggKMVqh7sjQgTaGZNShdz uxtxTTLff8asCNC3pRdHbj077CbhD6AMRVVtq2MktzrjWkurhk/F9q0G53FFh6MqjFqa 1il5BVrgzJxQEReXfsgzhKOLC+zwcBVai+Dyb/f09bnVTOrauqSlVs58XTKggFL3uPzK X9rtQ6xfc6qwiT1nNZB+aXF5ht7/qixvbhU2XXGJwqrvRdAUQTP9bf80l2KoI0+4WhPl w9v0uBkZrM0XCJ9jhOS718vkmMCyb/RIVzjWWbeoTJ3RRiu7Chpj2w6JPxuKn63l3A3O jRMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:references :in-reply-to:message-id:date:to:from:arc-authentication-results; bh=vlJz97NO5C1hqNTXuhAMZNb233r7m6C2DTP1UNV2uO4=; b=0GhmHbuKQyq/QUHZgMbB8JZeiG0FLOUMW5UaRp6l6niNSa91rqqopESFnUtEbMKoFo s5RS9xvWJuPykqSslk2c2u+tz1ZPM+fjZ4ZZq/CFossBhhiXE2oZ6ceM+gRAv2PJpYlL o1MFfxQs/HmY30ZGFzg791M/h13aRrtICLIP/qL1Lebs0Zg/hgQE3c1daOJ18rHqoChX PN4/Rqcu5xYVnkivXEM60/gtuTWKtodNGTn8zR98WuIQ2naskbbZCMFd0RXy6JghLrYC 80Fn3wi6cJDJxGijvKzaD3GmHPjWBZCgBhATjt91M2lU7+yRW7jVxBpjk5EoRazbhSnq GXyA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id h9si5307073edf.446.2017.11.28.02.34.22; Tue, 28 Nov 2017 02:34:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id D4628C21E18; Tue, 28 Nov 2017 10:26:50 +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=0.0 required=5.0 tests=none 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 E561BC21DF7; Tue, 28 Nov 2017 10:25:04 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 38245C21DF0; Tue, 28 Nov 2017 10:24:54 +0000 (UTC) Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id 78A47C21DA5 for ; Tue, 28 Nov 2017 10:24:54 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id CB9B420752; Tue, 28 Nov 2017 11:24:53 +0100 (CET) Received: from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id A223920380; Tue, 28 Nov 2017 11:24:53 +0100 (CET) From: Maxime Ripard To: Tom Rini Date: Tue, 28 Nov 2017 11:24:39 +0100 Message-Id: X-Mailer: git-send-email 2.14.3 In-Reply-To: References: In-Reply-To: References: Cc: Thomas Petazzoni , u-boot@lists.denx.de, Andre Przywara , agraf@suse.de, Maxime Ripard , Jagan Teki Subject: [U-Boot] [PATCH 04/14] env: Make the env save message a bit more explicit 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Since we'll soon have support for multiple environments, the environment saving message might end up being printed multiple times if the higher priority environment cannot be used. That might confuse the user, so let's make it explicit if the operation failed or not. Reviewed-by: Lukasz Majewski Signed-off-by: Maxime Ripard Reviewed-by: Andre Przywara Reviewed-by: Simon Glass --- env/env.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/env/env.c b/env/env.c index 673bfa6ba41b..1d13220aa79b 100644 --- a/env/env.c +++ b/env/env.c @@ -131,8 +131,9 @@ int env_save(void) if (!drv->save) continue; - printf("Saving Environment to %s...\n", drv->name); + printf("Saving Environment to %s... ", drv->name); ret = drv->save(); + printf("%s\n", ret ? "Failed" : "OK"); if (!ret) return 0; From patchwork Tue Nov 28 10:24:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 119824 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2911893edl; Tue, 28 Nov 2017 02:30:45 -0800 (PST) X-Google-Smtp-Source: AGs4zMaGA23xzfpDNlPbcfrOCQojh8nCMI3qrzpR1PG9M5kdmaSN3rFqzRAUIqzxBMaGYvr3y+eT X-Received: by 10.80.180.187 with SMTP id w56mr1933676edd.15.1511864911507; Tue, 28 Nov 2017 02:28:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511864911; cv=none; d=google.com; s=arc-20160816; b=valH19hQIgGx3WyIe08+LMth4bIBecTWFws1+p7ibtKCZMR3mgnXCSuOmpLjc2mMhg iq0uu1D4bTjr/E0+z9XwbQ1pOgAz/au+uCEDP2VygH8BX8Jj3JG4/w7b4YFuv24vxW6b ZbGxQn5M7WnR3MFhvS0TnTiKwo5VOlinsqPsBi3ljDO4CGTfUr393PhMe1qWyg5LB5Po dwa8XNdjCLYHCGCOW1SV8DxqP7a/e6rEf86EWMueUdqGErbUa+xZSRpqTxG65MgQMPc1 S2ov7LJwWSP7hIc1utB8/BI4PRZkEaI4w2dPKqzc4TNJyKlJo05yrmwWd3Oav42t2+Ja +fbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:references :in-reply-to:message-id:date:to:from:arc-authentication-results; bh=GOxmTi2ntFXqZ6VqwEJ24/KQyzmhCBBse+JNs5J7yaE=; b=omy1B/ornBBjGQYZOGQ5pfSafmlYmw9zOqBrN1Em5n3lK5WsTQe95vYU81ZkSZA+eC r268ZIONyH0RFKSvM42aTDtcBYqNmhU4uN1g/QUi62/9GaeWvBtvb4+U82eRaOqGlwM3 EE2QYjitN8nG7zjaptW/i4+7ni1Lj1iQrEIIO/u0OAmQkt4r3+UUWX8wXDtpnO3jrwtK 9BUsPCfKrxuwiowjsq1D/FWvj6mjJdqWLGCGfGO1I2Ac0bC0QpGuNJMK9p+RJ6HLQVDX hcNMHnN+n2JASYjJ+yVkEFxZBJ+B0siQK/jukanef5eONXdLBuPokMOOeF577OkP7HnC rWZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id f14si8071502edb.205.2017.11.28.02.28.31; Tue, 28 Nov 2017 02:28:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 094BEC21DE5; Tue, 28 Nov 2017 10:27:08 +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=0.0 required=5.0 tests=none 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 0DF00C21DDF; Tue, 28 Nov 2017 10:25:08 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 1335FC21E4B; Tue, 28 Nov 2017 10:24:57 +0000 (UTC) Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id D3F09C21DA2 for ; Tue, 28 Nov 2017 10:24:54 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 3415B207AF; Tue, 28 Nov 2017 11:24:54 +0100 (CET) Received: from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 0D36320380; Tue, 28 Nov 2017 11:24:54 +0100 (CET) From: Maxime Ripard To: Tom Rini Date: Tue, 28 Nov 2017 11:24:40 +0100 Message-Id: <45c910bdc2ad56e4ab10612ca801692812b3bbfc.1511864667.git-series.maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: References: In-Reply-To: References: Cc: Thomas Petazzoni , u-boot@lists.denx.de, Andre Przywara , agraf@suse.de, Maxime Ripard , Jagan Teki Subject: [U-Boot] [PATCH 05/14] env: Make it explicit where we're loading our environment from 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Since we can have multiple environments now, it's better to provide a decent indication on what environments were tried and which were the one to fail and succeed. Signed-off-by: Maxime Ripard Reviewed-by: Simon Glass --- env/env.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/env/env.c b/env/env.c index 1d13220aa79b..44f9908e2c2d 100644 --- a/env/env.c +++ b/env/env.c @@ -109,12 +109,11 @@ int env_load(void) if (!drv->load) continue; + printf("Loading Environment from %s... ", drv->name); ret = drv->load(); + printf("%s\n", ret ? "Failed" : "OK"); if (!ret) return 0; - - debug("%s: Environment %s failed to load (err=%d)\n", __func__, - drv->name, ret); } return -ENODEV; From patchwork Tue Nov 28 10:24:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 119828 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2915423edl; Tue, 28 Nov 2017 02:34:20 -0800 (PST) X-Google-Smtp-Source: AGs4zMb/rzflAHlHkxgYxTO+cXmNdqAiYzVtnpC7FS6LxbXVXNf5Syp/nLAJhne2k0lO0uHEOVzF X-Received: by 10.80.153.142 with SMTP id m14mr1936518edb.265.1511865260833; Tue, 28 Nov 2017 02:34:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511865260; cv=none; d=google.com; s=arc-20160816; b=rseULL1/NWEAO8S35NM9+CxhpV+4jVNm8rKTy0nckNjvkD72b6EwEd/K00xkFGSL9c tHHOYjzMbq3vZQ3aOpDkXQtj90Vd8QdCrUu2k1j8NzVuuSKdHvI0DxBjHLKkrW2nVJgl NW3jlnR48DKfNbUnNyMxlDJuHqMCaylNCEh2TaOV1nIxawO3ff7eUgbN9O7euDdvEGXN eszZZKDas7zH2tcVCdv1KFE5ZG8aqeCGNwlt5dSS5J6Sqi+BUdI7CSEJMmZGa0zGHgV0 41IV1hnHnqOn5RrKlPNgXf6L6x6DXhJO2TS3qkTSBSXOzOsq3MrE2llCTv+KUSZD+3nk rVjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:references :in-reply-to:message-id:date:to:from:arc-authentication-results; bh=oO9MtTcvr69eNot3E39O5Km1Sb5sF4qfe0opgagvwMk=; b=zEeObR40bYUuBjLTEwI3n2bnZE4yxvojwSzZjCfhA/k6nex+jemjP9aRiIMSPuTQSc ps1pzbsV2qG0UbEwouWirOTQT9qK7M1U18SYgj/SvuSp1pvEzyoQklQlOKxWYLveRvKc O2Dma+XL9RNMc747kgQuIQLhinwM1MaCwwrHrqWSZwky9e8fifVFBduFsOsNGHOKtnli Hnkf/d/KAuv1RsjplzF16RcdFYn8qFRJyJFGfwLfiAQAuGd4RchcjCs2zdDpu9pp3JDc cxIIbgx04rx5HJxu6E00aWXbzDxrz4/bVTJQWyVg1tRizWS6H81iohiWfaRZyOrnjgRl pAyg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id 63si2188788edn.533.2017.11.28.02.34.20; Tue, 28 Nov 2017 02:34:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 65FA8C21E5D; Tue, 28 Nov 2017 10:28:35 +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=0.0 required=5.0 tests=none 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 2E596C21E73; Tue, 28 Nov 2017 10:25:19 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 8B24BC21E22; Tue, 28 Nov 2017 10:24:59 +0000 (UTC) Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id 41B47C21DB2 for ; Tue, 28 Nov 2017 10:24:55 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 9647E207CA; Tue, 28 Nov 2017 11:24:54 +0100 (CET) Received: from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 6CB6F20380; Tue, 28 Nov 2017 11:24:54 +0100 (CET) From: Maxime Ripard To: Tom Rini Date: Tue, 28 Nov 2017 11:24:41 +0100 Message-Id: <5182ffa17460b2ab92ca5d33361964c24f31274d.1511864667.git-series.maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: References: In-Reply-To: References: Cc: Thomas Petazzoni , u-boot@lists.denx.de, Andre Przywara , agraf@suse.de, Maxime Ripard , Jagan Teki Subject: [U-Boot] [PATCH 06/14] env: fat: Make the debug messages play a little nicer 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Since we have global messages to indicate what's going on, the custom messages in the environment drivers only make the output less readable. Make FAT play a little nicer by removing all the extra \n and formatting that is redundant with the global output. Signed-off-by: Maxime Ripard Reviewed-by: Andre Przywara --- env/fat.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/env/fat.c b/env/fat.c index ec49c3905369..51c4cedda6be 100644 --- a/env/fat.c +++ b/env/fat.c @@ -55,7 +55,7 @@ static int env_fat_save(void) dev = dev_desc->devnum; if (fat_set_blk_dev(dev_desc, &info) != 0) { - printf("\n** Unable to use %s %d:%d for saveenv **\n", + printf("Unable to use %s %d:%d... ", CONFIG_ENV_FAT_INTERFACE, dev, part); return 1; } @@ -63,12 +63,11 @@ static int env_fat_save(void) err = file_fat_write(CONFIG_ENV_FAT_FILE, (void *)&env_new, 0, sizeof(env_t), &size); if (err == -1) { - printf("\n** Unable to write \"%s\" from %s%d:%d **\n", + printf("Unable to write \"%s\" from %s%d:%d... ", CONFIG_ENV_FAT_FILE, CONFIG_ENV_FAT_INTERFACE, dev, part); return 1; } - puts("done\n"); return 0; } #endif /* CMD_SAVEENV */ @@ -90,14 +89,14 @@ static int env_fat_load(void) dev = dev_desc->devnum; if (fat_set_blk_dev(dev_desc, &info) != 0) { - printf("\n** Unable to use %s %d:%d for loading the env **\n", + printf("Unable to use %s %d:%d... ", CONFIG_ENV_FAT_INTERFACE, dev, part); goto err_env_relocate; } err = file_fat_read(CONFIG_ENV_FAT_FILE, buf, CONFIG_ENV_SIZE); if (err == -1) { - printf("\n** Unable to read \"%s\" from %s%d:%d **\n", + printf("Unable to read \"%s\" from %s%d:%d... ", CONFIG_ENV_FAT_FILE, CONFIG_ENV_FAT_INTERFACE, dev, part); goto err_env_relocate; } From patchwork Tue Nov 28 10:24:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 119827 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2912815edl; Tue, 28 Nov 2017 02:31:34 -0800 (PST) X-Google-Smtp-Source: AGs4zMbJrxcROXug2NT1iSDLUWl5BB2HVp12bj9RL/+PJor4cPvqeIEaXq5ZrLkYC2gjrdc1/78d X-Received: by 10.80.181.70 with SMTP id z6mr1969500edd.201.1511865094691; Tue, 28 Nov 2017 02:31:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511865094; cv=none; d=google.com; s=arc-20160816; b=h43IK1gLgbJurLzJDJWKitbafsC9usU9eg4KihRCHQSyNA6DT/kiAxhGA5E9In5BzW SGkwfoYMFBEZn02D1rE22vq5xFOs53b3qDSS8ITKJb8ogz3VABk4f5dkC8L44StzOm1H OXgRvkUsa4GUjNQNm285H0KxnRbAT8d56LVFvK7k6Cl6cJHwwL1NoA0uTkdlC6EUT5/U UMXr0u4Mo/It7wqIjyArHLD4x4dwDNnNJw1dyM806KKoBhq5/gbYqhGBHiXLoSKwrRvZ QdPO9aUyh2bzAN/hsqiY0At6gfp+no/UypkXL3gjQFBOBmHgNwGq3foHgEMLgjQ6k3p6 hDHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:references :in-reply-to:message-id:date:to:from:arc-authentication-results; bh=9yrrR1J5xdxEehV4YqkL6oaufwYR/7U8hrTkBGkc5eQ=; b=E9umFhxotj35JwzC7EAs7HS7ZwGbg+gBxH/PJdc245VKUWNF8btIcgPSbjdPQy4oML 3xqOpR5dTH4BEHH3QwldkifvqZ45Ww36nOgOtBcWb3bg6OPxmWVggptc3iNDCiayiKQM Bp8si/kkBip/tWRViUaBH1mXblRdbG0fGJslQFtVzSBCHzTA3PUjFJOOKBGkUvKgXECm IcaVYaaQVLIDZ55Hxz/metzLO4nUBNJH+y7qpfe+SFxLQjWQftAIgA0rZ56TgLy3HjC+ 9P01CTc5Wcg0jmr3gM4C3BRz08AjgzyAMXDiZ8wpVbsz4X25eB0mLCVuuVNxhS/GNu/C 9RDA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id 65si1099831edj.513.2017.11.28.02.31.34; Tue, 28 Nov 2017 02:31:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 570B7C21E71; Tue, 28 Nov 2017 10:28:01 +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=0.0 required=5.0 tests=none 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 07551C21DF4; Tue, 28 Nov 2017 10:25:14 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 96D6CC21DA5; Tue, 28 Nov 2017 10:25:00 +0000 (UTC) Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id A09B0C21DDA for ; Tue, 28 Nov 2017 10:24:55 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 0014C207CC; Tue, 28 Nov 2017 11:24:54 +0100 (CET) Received: from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id CD94A20380; Tue, 28 Nov 2017 11:24:54 +0100 (CET) From: Maxime Ripard To: Tom Rini Date: Tue, 28 Nov 2017 11:24:42 +0100 Message-Id: X-Mailer: git-send-email 2.14.3 In-Reply-To: References: In-Reply-To: References: Cc: Thomas Petazzoni , u-boot@lists.denx.de, Andre Przywara , agraf@suse.de, Maxime Ripard , Jagan Teki Subject: [U-Boot] [PATCH 07/14] env: mmc: Make the debug messages play a little nicer 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Since we have global messages to indicate what's going on, the custom messages in the environment drivers only make the output less readable. Make MMC play a little nicer by removing all the extra \n and formatting that is redundant with the global output. Signed-off-by: Maxime Ripard Reviewed-by: Andre Przywara --- env/mmc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/env/mmc.c b/env/mmc.c index 3f3092d97560..885e000307db 100644 --- a/env/mmc.c +++ b/env/mmc.c @@ -179,7 +179,6 @@ static int env_mmc_save(void) goto fini; } - puts("done\n"); ret = 0; #ifdef CONFIG_ENV_OFFSET_REDUND From patchwork Tue Nov 28 10:24:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 119821 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2910958edl; Tue, 28 Nov 2017 02:29:52 -0800 (PST) X-Google-Smtp-Source: AGs4zMYxKQjW5SmGheI1HPiLOhsGafh8pnzEIVImiWM3deUqFn0Y+kyCQgrFqdhotJcX5hhMohGW X-Received: by 10.80.146.227 with SMTP id l32mr2049776eda.114.1511864992499; Tue, 28 Nov 2017 02:29:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511864992; cv=none; d=google.com; s=arc-20160816; b=JblZysMc+2AtGoGGLW4sTqZ8qP3U0vlurFZej/gGV7I1xcibZSglNFc+mJ0gbFwbgg 1Yq+Z5HRDdaZlxK10qngqprIR5E/cNlE0LP79nWYnZHwCq5o3Xf7BtG+8KcrEK8/5YMx F94HC/ZPllGMWsZT3wFSuGivpYpDwSQ7IShIOkhWei9YwzM+mgG0JrCqzA+Rq1tzHFWg 1gIUnpj4R8GzkdxxO7g9ucaeoKtg2dM21XBOsfb2eIqnhp0EVv0BSsiwa+V4BOfgvGs5 Xen2yaMn3gJ8ASic59AcI+BvkccjgbZhGzbyTjnedeTUALqVOQjKLKo6Odj8Gnj4laZw F4hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:references :in-reply-to:message-id:date:to:from:arc-authentication-results; bh=nguTi4FofPQvrpVsjR9c6Q+SDPvpmx908CyCXM0g7/k=; b=YadarunSZGFODpmaXgMfsUCyHPyQEN8RFA8130Wx1v3V5dsoLNLFMcsRH8BeBqg1mj RmgoNPAhrvksJ+TfdxnD8aFZ2odDCUhBUg3UNP+pYia0rAHSzjieQ8RuMID1h4DhBI19 NbC2RTDlHdo54OArOa0ubvlCdLSXxLwi6Y5G8Vxw6ETQWewCdanYyYwml8zEUlEtmvjw F1bjsbpQ43Ryo5aDT3a809iZOZV74cc2Gp3kqE1hFAWeO1fQmtHpnNndjGCq3WE1ymnO kxFMqsQKrjNpfJxUkxbMh0it6bIheQyiEBBxOcWw98rI692cLEvftp1EO6NNKCRhUUmf Wmjw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id q41si2708095eda.93.2017.11.28.02.29.52; Tue, 28 Nov 2017 02:29:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 27237C21DED; Tue, 28 Nov 2017 10:27:26 +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=0.0 required=5.0 tests=none 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 EAD51C21E3E; Tue, 28 Nov 2017 10:25:08 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id B685FC21E22; Tue, 28 Nov 2017 10:25:01 +0000 (UTC) Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id 10733C21DE7 for ; Tue, 28 Nov 2017 10:24:56 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 64C982081A; Tue, 28 Nov 2017 11:24:55 +0100 (CET) Received: from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 3C53020380; Tue, 28 Nov 2017 11:24:55 +0100 (CET) From: Maxime Ripard To: Tom Rini Date: Tue, 28 Nov 2017 11:24:43 +0100 Message-Id: X-Mailer: git-send-email 2.14.3 In-Reply-To: References: In-Reply-To: References: Cc: Thomas Petazzoni , u-boot@lists.denx.de, Andre Przywara , agraf@suse.de, Maxime Ripard , Jagan Teki Subject: [U-Boot] [PATCH 08/14] env: common: Make the debug messages play a little nicer 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Since we have global messages to indicate what's going on, the custom messages in the environment drivers only make the output less readable. Make the common code play a little nicer by removing all the extra output in the standard case. Signed-off-by: Maxime Ripard Reviewed-by: Andre Przywara --- env/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/env/common.c b/env/common.c index 70715bb6e756..fb66432bdc81 100644 --- a/env/common.c +++ b/env/common.c @@ -78,7 +78,7 @@ void set_default_env(const char *s) puts(s); } } else { - puts("Using default environment\n\n"); + debug("Using default environment\n\n"); } if (himport_r(&env_htab, (char *)default_environment, From patchwork Tue Nov 28 10:24:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 119822 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2911612edl; Tue, 28 Nov 2017 02:30:29 -0800 (PST) X-Google-Smtp-Source: AGs4zMaDSlLM5a5OTgSgUQh7K9d4c+v9VIknhyzDOcPpcRUhQ8adgmEFQ+Vv/oUZYRRMd7iwWGgw X-Received: by 10.80.220.132 with SMTP id r4mr2045287edk.180.1511865029298; Tue, 28 Nov 2017 02:30:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511865029; cv=none; d=google.com; s=arc-20160816; b=flCiBmJs7zRjR48iufoeg/N4NXepBTcPHTgzvSgNvilErTRHMJ0uyffIy4Jfh7oTQb paFgUvLhj6g7qURmaEbsssw8nqBDfe/xncwAIu+A3D6UeUN7IJQuzD3yq5ygX2wZkgKm pZ/Y5PabtmYYtUDY65gBW9NTx5L1DiRUun7YcehMc7/y8ScY4CR4Y/K6GqIww5vErb7n OaD040Q5SeSzYsDv4Prqe43w8pi1BMOsnzsHWXEK+nb1tqVk9HcfnBJIVhegViJjI3ra oq1kCCzTulF20eppmv991C18fm0KohTQISgTIO5RwkxX7bjly2CXfTVlBCdVKZ/LxtwG zMLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:references :in-reply-to:message-id:date:to:from:arc-authentication-results; bh=ry63qEcjqKTpO/YQ0UUv1FrqW3TH9oNewJyzGkuZJP8=; b=M673AxLkW0EclM6/hFNV7CEh/ZZshDF6QgD0PsvRhNPpwxk1OfW0ZDp+CNbeUS6HNk NOr/dRHxuBGuivFRtBbi0TDHrQ4NRXtGgDf5GOhEielvBvAWVtRDqXGGINVW0ExPGYTa SEYmrqPdW2N2THczk5EG5ofBSSnOSk0Ehh+gIO95vWn/e284zH6e21xZAwbPBklynv6/ 5YLkr7Rm2zkfKiAyjoEgnjn04FMpTWJFhM4I3U331EleiONAbaAtalKYveeb0Vtolol/ KBh6V6RHowOc+Wg0YMkRzOFqBsiI0HBjmwIHz/5Mn8sNrsCsbLy2W7TgsxFywhpQ2Qng zCBw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id 5si5480108edx.248.2017.11.28.02.30.28; Tue, 28 Nov 2017 02:30:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id B7BF1C21E2F; Tue, 28 Nov 2017 10:27:44 +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=0.0 required=5.0 tests=none 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 16F33C21DA5; Tue, 28 Nov 2017 10:25:13 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 3EF24C21DE7; Tue, 28 Nov 2017 10:25:02 +0000 (UTC) Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id 738D3C21DF7 for ; Tue, 28 Nov 2017 10:24:56 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id C73F1203B5; Tue, 28 Nov 2017 11:24:55 +0100 (CET) Received: from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 9CFED2083F; Tue, 28 Nov 2017 11:24:55 +0100 (CET) From: Maxime Ripard To: Tom Rini Date: Tue, 28 Nov 2017 11:24:44 +0100 Message-Id: <2b747a810c8103878d673660bbdc560431d19c73.1511864667.git-series.maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: References: In-Reply-To: References: Cc: Thomas Petazzoni , u-boot@lists.denx.de, Andre Przywara , agraf@suse.de, Maxime Ripard , Jagan Teki Subject: [U-Boot] [PATCH 09/14] env: Support multiple environments 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Now that we have everything in place to support multiple environment, let's make sure the current code can use it. The priority used between the various environment is the same one that was used in the code previously. At read / init times, the highest priority environment is going to be detected, and we'll use the same one without lookup during writes. This should implement the same behaviour than we currently have. Signed-off-by: Maxime Ripard Reviewed-by: Simon Glass --- env/env.c | 75 +++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 50 insertions(+), 25 deletions(-) diff --git a/env/env.c b/env/env.c index 44f9908e2c2d..5176700133d3 100644 --- a/env/env.c +++ b/env/env.c @@ -26,33 +26,58 @@ static struct env_driver *_env_driver_lookup(enum env_location loc) return NULL; } +static enum env_location env_locations[] = { +#ifdef CONFIG_ENV_IS_IN_EEPROM + ENVL_EEPROM, +#endif +#ifdef CONFIG_ENV_IS_IN_FAT + ENVL_FAT, +#endif +#ifdef CONFIG_ENV_IS_IN_FLASH + ENVL_FLASH, +#endif +#ifdef CONFIG_ENV_IS_IN_MMC + ENVL_MMC, +#endif +#ifdef CONFIG_ENV_IS_IN_NAND + ENVL_NAND, +#endif +#ifdef CONFIG_ENV_IS_IN_NVRAM + ENVL_NVRAM, +#endif +#ifdef CONFIG_ENV_IS_IN_REMOTE + ENVL_REMOTE, +#endif +#ifdef CONFIG_ENV_IS_IN_SPI_FLASH + ENVL_SPI_FLASH, +#endif +#ifdef CONFIG_ENV_IS_IN_UBI + ENVL_UBI, +#endif +#ifdef CONFIG_ENV_IS_NOWHERE + ENVL_NOWHERE, +#endif + ENVL_UNKNOWN, +}; + +static enum env_location env_load_location; + static enum env_location env_get_location(enum env_operation op, int prio) { - if (prio >= 1) - return ENVL_UNKNOWN; - - if IS_ENABLED(CONFIG_ENV_IS_IN_EEPROM) - return ENVL_EEPROM; - else if IS_ENABLED(CONFIG_ENV_IS_IN_FAT) - return ENVL_FAT; - else if IS_ENABLED(CONFIG_ENV_IS_IN_FLASH) - return ENVL_FLASH; - else if IS_ENABLED(CONFIG_ENV_IS_IN_MMC) - return ENVL_MMC; - else if IS_ENABLED(CONFIG_ENV_IS_IN_NAND) - return ENVL_NAND; - else if IS_ENABLED(CONFIG_ENV_IS_IN_NVRAM) - return ENVL_NVRAM; - else if IS_ENABLED(CONFIG_ENV_IS_IN_REMOTE) - return ENVL_REMOTE; - else if IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH) - return ENVL_SPI_FLASH; - else if IS_ENABLED(CONFIG_ENV_IS_IN_UBI) - return ENVL_UBI; - else if IS_ENABLED(CONFIG_ENV_IS_NOWHERE) - return ENVL_NOWHERE; - else - return ENVL_UNKNOWN; + switch (op) { + case ENVO_GET_CHAR: + case ENVO_INIT: + case ENVO_LOAD: + if (prio >= ARRAY_SIZE(env_locations)) + return -ENODEV; + + return env_load_location = env_locations[prio]; + + case ENVO_SAVE: + return env_load_location; + } + + return ENVL_UNKNOWN; } static struct env_driver *env_driver_lookup(enum env_operation op, int prio) From patchwork Tue Nov 28 10:24:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 119818 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1514746qgn; Tue, 28 Nov 2017 02:26:09 -0800 (PST) X-Google-Smtp-Source: AGs4zMa5ojjTu0GASDBB/B8bwHya2kZkS/kCsWMPmqAqhhijWvw+96yq/G3zK3abGvWfNM/Ly8Xj X-Received: by 10.80.144.168 with SMTP id c37mr1988005eda.182.1511864769189; Tue, 28 Nov 2017 02:26:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511864769; cv=none; d=google.com; s=arc-20160816; b=mwFWlwgOPvbER33BRy/iyVjDHU7KojDGufvt6SYQBkaeeyhpRyGFPgzwZcD64xjV+O 0zr4wlx+wrKf518wFP5ZVAPFFWp4NG6Croigr3c8MBiCoUJ9RMknMactpVyxSlGG6buQ lEEQOvR3tcSmfgjJavMYgAvwKdKpqpGCGxjkMspjQih1203cQKFH1hOIdPynm6/nrgC1 lwr8RuHnMLF501h2ShKOORKEsJOK2xLSWM5AndaHM9VeM+3kq1JxYAYfXUL61Rc909KC G3McHS4yPhelNgQkJ5Stxk6uU4/XMAb7f9GD5E0YGRlsn91OPt3ua6T5qHyM/9nBtLcw FuFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:references :in-reply-to:message-id:date:to:from:arc-authentication-results; bh=s6JI2cbE88LLz6IB+CfId6uPjEIcaMPLDzvqIO5raio=; b=Kw/mlToH3faOj3S/Qs3BxkSauXOUcMiBvI5TeHMx9yfSc6oWUdU8ypg1x7ZRRSyEqj PilImFj77UFEqX17j3jTcmTrbxFAUXXAduOOWcm+zm4lpFADPpe0+Xpj4vO6a7VaVvB8 29H/AKCnXJuzdQ2wSbSUbTNEiqOyMM0VghcOD3HGEprcW2Q9NT1USYs3gKoSkR1Lb4rz KKm3ShPM85wVikNZT6r6uFB3sCGInPUupVKHxor6vc8Anlov0AZZNdh8A8Is+DR4q3Zj rVuEObVQ1tRlh184SFO6Y8II1X8FXZxnt/kJ06RRinIUldV3LzdDhVcp2HZ5wZ5ZsjTn /vnw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id r12si17394966edd.356.2017.11.28.02.26.08; Tue, 28 Nov 2017 02:26:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id B4FEEC21E30; Tue, 28 Nov 2017 10:25:19 +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=0.0 required=5.0 tests=none 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 95E56C21DD9; Tue, 28 Nov 2017 10:24:55 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id DB922C21D6A; Tue, 28 Nov 2017 10:24:52 +0000 (UTC) Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id 8EBF8C21D79 for ; Tue, 28 Nov 2017 10:24:52 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id DF3FE20742; Tue, 28 Nov 2017 11:24:51 +0100 (CET) Received: from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id B5F5D20380; Tue, 28 Nov 2017 11:24:51 +0100 (CET) From: Maxime Ripard To: Tom Rini Date: Tue, 28 Nov 2017 11:24:45 +0100 Message-Id: X-Mailer: git-send-email 2.14.3 In-Reply-To: References: In-Reply-To: References: Cc: Thomas Petazzoni , u-boot@lists.denx.de, Andre Przywara , agraf@suse.de, Maxime Ripard , Jagan Teki Subject: [U-Boot] [PATCH 10/14] env: Initialise all the environments 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Since we want to have multiple environments, we will need to initialise all the environments since we don't know at init time what drivers might fail when calling load. Let's init all of them, and only consider for further operations the ones that have not reported any errors at init time. Signed-off-by: Maxime Ripard --- env/env.c | 19 ++++++++++++------- include/asm-generic/global_data.h | 1 + 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/env/env.c b/env/env.c index 5176700133d3..b4d8886e7a69 100644 --- a/env/env.c +++ b/env/env.c @@ -112,6 +112,9 @@ int env_get_char(int index) if (!drv->get_char) continue; + if (!(gd->env_has_init & BIT(drv->location))) + continue; + ret = drv->get_char(index); if (!ret) return 0; @@ -134,6 +137,9 @@ int env_load(void) if (!drv->load) continue; + if (!(gd->env_has_init & BIT(drv->location))) + continue; + printf("Loading Environment from %s... ", drv->name); ret = drv->load(); printf("%s\n", ret ? "Failed" : "OK"); @@ -155,6 +161,9 @@ int env_save(void) if (!drv->save) continue; + if (!(gd->env_has_init & BIT(drv->location))) + continue; + printf("Saving Environment to %s... ", drv->name); ret = drv->save(); printf("%s\n", ret ? "Failed" : "OK"); @@ -175,14 +184,10 @@ int env_init(void) int prio; for (prio = 0; (drv = env_driver_lookup(ENVO_INIT, prio)); prio++) { - if (!drv->init) - continue; - - ret = drv->init(); - if (!ret) - return 0; + if (!drv->init || !drv->init()) + gd->env_has_init |= BIT(drv->location); - debug("%s: Environment %s failed to init (err=%d)\n", __func__, + debug("%s: Environment %s init done (ret=%d)\n", __func__, drv->name, ret); } diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index 944f58195caf..1d0611fe9498 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -50,6 +50,7 @@ typedef struct global_data { #endif unsigned long env_addr; /* Address of Environment struct */ unsigned long env_valid; /* Environment valid? enum env_valid */ + unsigned long env_has_init; /* Bitmask of boolean of struct env_location offsets */ unsigned long ram_top; /* Top address of RAM used by U-Boot */ unsigned long relocaddr; /* Start address of U-Boot in RAM */ From patchwork Tue Nov 28 10:24:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 119820 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1516346qgn; Tue, 28 Nov 2017 02:27:55 -0800 (PST) X-Google-Smtp-Source: AGs4zMaVmeP3yQ+v95O3GQpqPN90ssVRuzO36IrNwvruNpOopbr25Qk5nZ4tudCgRcsJIisM6WF6 X-Received: by 10.80.147.16 with SMTP id m16mr1935168eda.121.1511864875846; Tue, 28 Nov 2017 02:27:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511864875; cv=none; d=google.com; s=arc-20160816; b=C8MWzWmcDdPRxQMRFf28rPr4SdkLAR7BGfGYzZC3ppHADMSiRtRwKamti4rKNFcOwr kZwBK7JOWA+fPrBclnMcjW3HZr2ryrkh+nqcWMa4GhrJjjh3W9asW8N3nDD/54Nw17Ef tA5yXYMGgzRzxcTHGiK2bMj1p9xhhBjVrrLR43rJCya0otOLT+VnnOrXp36W7oK6yeab yVhMeTlUljH66X4nIJn6ifP3Wijz22vW+IWbSd6RRFJaQRMZijlDcfMxdGSTFVb/2zt8 MC2b70xaDfJQSJ2o4um5nCgbzb/aEbGX8Mg7xUUeGPt6ZRfF91L2YG5qMGkH+cQAl5dk Zv5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:references :in-reply-to:message-id:date:to:from:arc-authentication-results; bh=j53bzARFPrmS9/G+7Ls6h+4ojx8F6gxRVsACVgd8lw8=; b=WgAKh/Z6uGBf31qLcRfGDXRQbsW2ayJZuTYwrajoqB/FDcXxiElDIZq9jIqb/3EZH3 PyCU8lCaGxEBgAM1n2igPpnhV4gbNXi9buFXU9Hdni0riSCeAXc0bbAJdpYdHNZebFyl KavJXdHY6dk4O/1EWO2milj67osD9awr902s2daSr+0rGKQE62K7kmUE2x9f5WS0hAVz sjGM4bbGgSgse3L+P0x4a9/2EUTPmRVxIQ/0aYRHCDke6hCVLMcB74HcKVj1OTikDijP 9uGgIA+rcRXL+HskfAs9IJj9zhQpc4aq8K6pDDsd3BAbcn4fEiWIPRYTR7J8STBrskfu Anig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id 94si200129edi.394.2017.11.28.02.27.55; Tue, 28 Nov 2017 02:27:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 473F7C21E14; Tue, 28 Nov 2017 10:25:38 +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=0.0 required=5.0 tests=none 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 896C3C21E0C; Tue, 28 Nov 2017 10:24:56 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 46726C21DA0; Tue, 28 Nov 2017 10:24:53 +0000 (UTC) Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id EECB2C21D79 for ; Tue, 28 Nov 2017 10:24:52 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 4AC0720743; Tue, 28 Nov 2017 11:24:52 +0100 (CET) Received: from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 21F6520380; Tue, 28 Nov 2017 11:24:52 +0100 (CET) From: Maxime Ripard To: Tom Rini Date: Tue, 28 Nov 2017 11:24:46 +0100 Message-Id: X-Mailer: git-send-email 2.14.3 In-Reply-To: References: In-Reply-To: References: Cc: Thomas Petazzoni , u-boot@lists.denx.de, Andre Przywara , agraf@suse.de, Maxime Ripard , Jagan Teki Subject: [U-Boot] [PATCH 11/14] env: Allow to build multiple environments in Kconfig 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Now that we have everything in place in the code, let's allow to build multiple environments backend through Kconfig. Reviewed-by: Lukasz Majewski Signed-off-by: Maxime Ripard Reviewed-by: Andre Przywara Reviewed-by: Simon Glass --- env/Kconfig | 65 ++++++++++++++++++++++++++---------------------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/env/Kconfig b/env/Kconfig index 8c9d800f485f..bf6eab6b4ace 100644 --- a/env/Kconfig +++ b/env/Kconfig @@ -1,38 +1,18 @@ menu "Environment" -choice - prompt "Select the location of the environment" - default ENV_IS_IN_MMC if ARCH_SUNXI - default ENV_IS_IN_MMC if ARCH_EXYNOS4 - default ENV_IS_IN_MMC if MX6SX || MX7D - default ENV_IS_IN_MMC if TEGRA30 || TEGRA124 - default ENV_IS_IN_MMC if TEGRA_ARMV8_COMMON - default ENV_IS_IN_FLASH if ARCH_CINTEGRATOR - default ENV_IS_IN_FLASH if ARCH_INTEGRATOR_CP - default ENV_IS_IN_FLASH if M548x || M547x || M5282 || MCF547x_8x - default ENV_IS_IN_FLASH if MCF532x || MCF52x2 - default ENV_IS_IN_FLASH if MPC86xx || MPC83xx - default ENV_IS_IN_FLASH if ARCH_MPC8572 || ARCH_MPC8548 || ARCH_MPC8641 - default ENV_IS_IN_FLASH if SH && !CPU_SH4 - default ENV_IS_IN_SPI_FLASH if ARMADA_XP - default ENV_IS_IN_SPI_FLASH if INTEL_BAYTRAIL - default ENV_IS_IN_SPI_FLASH if INTEL_BRASWELL - default ENV_IS_IN_SPI_FLASH if INTEL_BROADWELL - default ENV_IS_IN_SPI_FLASH if NORTHBRIDGE_INTEL_IVYBRIDGE - default ENV_IS_IN_SPI_FLASH if INTEL_QUARK - default ENV_IS_IN_SPI_FLASH if INTEL_QUEENSBAY - default ENV_IS_IN_FAT if ARCH_BCM283X - default ENV_IS_IN_FAT if MMC_OMAP_HS && TI_COMMON_CMD_OPTIONS - default ENV_IS_NOWHERE - help - At present the environment can be stored in only one place. Use this - option to select the location. This is either a device (where the - environemnt information is simply written to a fixed location or - partition on the device) or a filesystem (where the environment - information is written to a file). - config ENV_IS_NOWHERE bool "Environment is not stored" + depends on !ENV_IS_IN_EEPROM + depends on !ENV_IS_IN_FAT + depends on !ENV_IS_IN_FLASH + depends on !ENV_IS_IN_MMC + depends on !ENV_IS_IN_NAND + depends on !ENV_IS_IN_NVRAM + depends on !ENV_IS_IN_ONENAND + depends on !ENV_IS_IN_REMOTE + depends on !ENV_IS_IN_SPI_FLASH + depends on !ENV_IS_IN_UBI + default y help Define this if you don't want to or can't have an environment stored on a storage medium. In this case the environemnt will still exist @@ -74,6 +54,8 @@ config ENV_IS_IN_EEPROM config ENV_IS_IN_FAT bool "Environment is in a FAT filesystem" depends on !CHAIN_OF_TRUST + default y if ARCH_BCM283X + default y if MMC_OMAP_HS && TI_COMMON_CMD_OPTIONS select FAT_WRITE help Define this if you want to use the FAT file system for the environment. @@ -84,6 +66,13 @@ config ENV_IS_IN_FAT config ENV_IS_IN_FLASH bool "Environment in flash memory" depends on !CHAIN_OF_TRUST + default y if ARCH_CINTEGRATOR + default y if ARCH_INTEGRATOR_CP + default y if M548x || M547x || M5282 || MCF547x_8x + default y if MCF532x || MCF52x2 + default y if MPC86xx || MPC83xx + default y if ARCH_MPC8572 || ARCH_MPC8548 || ARCH_MPC8641 + default y if SH && !CPU_SH4 help Define this if you have a flash device which you want to use for the environment. @@ -156,6 +145,11 @@ config ENV_IS_IN_FLASH config ENV_IS_IN_MMC bool "Environment in an MMC device" depends on !CHAIN_OF_TRUST + default y if ARCH_SUNXI + default y if ARCH_EXYNOS4 + default y if MX6SX || MX7D + default y if TEGRA30 || TEGRA124 + default y if TEGRA_ARMV8_COMMON help Define this if you have an MMC device which you want to use for the environment. @@ -293,6 +287,13 @@ config ENV_IS_IN_REMOTE config ENV_IS_IN_SPI_FLASH bool "Environment is in SPI flash" depends on !CHAIN_OF_TRUST + default y if ARMADA_XP + default y if INTEL_BAYTRAIL + default y if INTEL_BRASWELL + default y if INTEL_BROADWELL + default y if NORTHBRIDGE_INTEL_IVYBRIDGE + default y if INTEL_QUARK + default y if INTEL_QUEENSBAY help Define this if you have a SPI Flash memory device which you want to use for the environment. @@ -358,8 +359,6 @@ config ENV_IS_IN_UBI You will probably want to define these to avoid a really noisy system when storing the env in UBI. -endchoice - config ENV_AES bool "AES-128 encryption for stored environment (DEPRECATED)" help From patchwork Tue Nov 28 10:24:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 119823 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2911646edl; Tue, 28 Nov 2017 02:30:31 -0800 (PST) X-Google-Smtp-Source: AGs4zMa9nrKicZ6a+gWqmDjAe8ocMugi7FVP9Ynr1xd6CSyAPaAEwJLZQeAeQexMFCBTHIXAzkzS X-Received: by 10.80.137.106 with SMTP id f39mr2047184edf.148.1511865030999; Tue, 28 Nov 2017 02:30:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511865030; cv=none; d=google.com; s=arc-20160816; b=IL4W/4s8EVFQEsExRG1SaTVZ1cR0aDYZKM94KSKAMJI5uayQJyiuMdjpa9enbuDN7y /ZeVONpvFcBLiKRQkB5/mHkk5poXQlHGzgqVhCYx6pQWtdttSsBSoZ7LKRyKkBGxUB6E Kad/6Gs+LXqB3e5nK1Il43dVtrBkNSW8y3gKllQ1uf2h8IijdTfEGIbomdHKH1kBL0ZP Upu6Pe+Uo0RwRHcWS3W435KFz7qPWIShhGc8N9yfNL33hKAdQtLZ9yEJQEU7GqD28EVG J8I2Y3pHogFEsX81zguDzVhaIL9HDNhl0tRkmLa25nzLN6O4KHRwcFf1Vq6raioAMez1 k0qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:references :in-reply-to:message-id:date:to:from:arc-authentication-results; bh=Tk4c+9c44IniNaroD9Ed+MAqrFlPlbO5C7WoeZea3Fk=; b=JJ4MnAJu4J8+mAJjfDE2evjwo+mXcyI9J2Owga9bxctwWxREQYd9MnZzTnsYJ4NDO0 VMve7rIlrew5GUFfNkd9SBjRG7Cyxzjg0wS9Uc3VnnS9cTGmg2Q4kw3OxhfRqmCP4CbY 88hZdNq0elXAqlVMuI1oGSonsii7gVXi4wbAqwvQ8VcyMPygr2v6pYtC60aHvvMFskuv hbho+OEZVJ4o6NYMRgEQbO18KkCGjqS4NLBP1BbIeC5C9Vi/0y2gHUMfkDmc4fXYAA4I f+z7cR2VWyxr3hpEMVStP2ivlcojRtpY5ot7qvS8grXof3HSRg8F0eJNmatOMLHjZNCD Nj5A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id s6si1048261edc.399.2017.11.28.02.30.30; Tue, 28 Nov 2017 02:30:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 8B92BC21DF3; Tue, 28 Nov 2017 10:28:18 +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=0.0 required=5.0 tests=none 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 2E5D0C21E74; Tue, 28 Nov 2017 10:25:16 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7F627C21E70; Tue, 28 Nov 2017 10:25:02 +0000 (UTC) Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id D7228C21DDB for ; Tue, 28 Nov 2017 10:24:56 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 36E642074B; Tue, 28 Nov 2017 11:24:56 +0100 (CET) Received: from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 0C7DA20380; Tue, 28 Nov 2017 11:24:56 +0100 (CET) From: Maxime Ripard To: Tom Rini Date: Tue, 28 Nov 2017 11:24:47 +0100 Message-Id: <537a3581d52c026ce964762a38cf65faed7c175c.1511864667.git-series.maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: References: In-Reply-To: References: Cc: Thomas Petazzoni , u-boot@lists.denx.de, Andre Przywara , agraf@suse.de, Maxime Ripard , Jagan Teki Subject: [U-Boot] [PATCH 12/14] env: Mark env_get_location as weak 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Allow boards and architectures to override the default environment lookup code by overriding env_get_location. Reviewed-by: Lukasz Majewski Signed-off-by: Maxime Ripard Reviewed-by: Andre Przywara --- env/env.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/env/env.c b/env/env.c index b4d8886e7a69..9b8b38cf3c2b 100644 --- a/env/env.c +++ b/env/env.c @@ -62,7 +62,7 @@ static enum env_location env_locations[] = { static enum env_location env_load_location; -static enum env_location env_get_location(enum env_operation op, int prio) +__weak enum env_location env_get_location(enum env_operation op, int prio) { switch (op) { case ENVO_GET_CHAR: From patchwork Tue Nov 28 10:24:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 119831 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2916940edl; Tue, 28 Nov 2017 02:36:13 -0800 (PST) X-Google-Smtp-Source: AGs4zMbO135RGGA774IY9TB1L+ESMuCXwDTlEOy4Ut1TcvoyWHLDiTIVQ1LN+HjeJ15vLxDGyfid X-Received: by 10.80.140.176 with SMTP id q45mr2087457edq.186.1511865373354; Tue, 28 Nov 2017 02:36:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511865373; cv=none; d=google.com; s=arc-20160816; b=x3JPFTyq7vaMQt6irYIXte0cx5bAABzsOQ+I6NJxeLJa/opHTdAJm9RpDN+48jYlEZ g4lPOUtMdXvTTOD5ojYeTgVrScyGWcMJQgjzBOPyi8yxNm5C+BVTyQbhrjDsDRrnciRV JiT9DhE30mtqaWBq/E//B123Ymn5WVudRWH7qNwgxBJt1I1Y+fOt4vNO2pkEGjhYGLc1 dj+/RbEpFdv2kOLav3/VAogIYCtdcPlEW4vLp0YLRsGM1OtpVo6TDvgOJyLrUvW0D24J w2tOEn/UQAlAIQIYG07qLvEO+6n0QJc5wi1fZeEpUqfSVNI2MhDaeW10PrHb+S8U+wYd kQEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:references :in-reply-to:message-id:date:to:from:arc-authentication-results; bh=qJ/06Su1fCfvNMjpHEPcY1JIrzz+FtNAjhQ0cjKxU1Y=; b=vyfdQEZq9Tb/XyIrS1qRM86tGT2y304EPd3qbJJoE4HB9ad7wIxRX27JNMa1KgzcNr dKXZUl0JgjGNSw7Fx7Ltq2GSwhxzQ3tBWGwOkIZZJWznDAQMBexrmzni/VIADvYV5yku FOIUGwLrlQXp4Z+FfgOeh05g9mFI8Nnn619rvTjmqe144MHO0+f6h1nts/YV9/JESuIv Je0O1DFhezyFrVa/OeaCkfJ9f+1F7OdOxhpmeNZDYrOHH0xHipktYJR4uZCkhdedgMa8 YS6XckbMpLZpQGPALJgflNMUHcbOdCmjadXzJ/BshxW0UDAFykTyG7/r9oy9nglT8VOQ JIxQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id n92si3817289edc.339.2017.11.28.02.36.13; Tue, 28 Nov 2017 02:36:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id E9EC6C21DB2; Tue, 28 Nov 2017 10:28:53 +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=0.0 required=5.0 tests=none 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 2201AC21E63; Tue, 28 Nov 2017 10:25:38 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 45D6AC21E22; Tue, 28 Nov 2017 10:25:02 +0000 (UTC) Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id 4ECCAC21DA2 for ; Tue, 28 Nov 2017 10:24:57 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 9E74D2083F; Tue, 28 Nov 2017 11:24:56 +0100 (CET) Received: from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 73C4720380; Tue, 28 Nov 2017 11:24:56 +0100 (CET) From: Maxime Ripard To: Tom Rini Date: Tue, 28 Nov 2017 11:24:48 +0100 Message-Id: X-Mailer: git-send-email 2.14.3 In-Reply-To: References: In-Reply-To: References: Cc: Thomas Petazzoni , u-boot@lists.denx.de, Andre Przywara , agraf@suse.de, Maxime Ripard , Jagan Teki Subject: [U-Boot] [PATCH 13/14] sunxi: Transition from the MMC to a FAT-based environment 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The current environment has been hardcoded to an offset that starts to be an issue given the current size of our main U-Boot binary. By implementing a custom environment location routine, we can always favor the FAT-based environment, and fallback to the MMC if we don't find something in the FAT partition. We also implement the same order when saving the environment, so that hopefully we can slowly migrate the users over to FAT-based environment and away from the raw MMC one. Eventually, and hopefully before we reach that limit again, we will have most of our users using that setup, and we'll be able to retire the raw environment, and gain more room for the U-Boot binary. Reviewed-by: Lukasz Majewski Signed-off-by: Maxime Ripard --- board/sunxi/board.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/board/sunxi/board.c b/board/sunxi/board.c index dcacdf3e626d..8891961dcc6b 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -173,6 +173,22 @@ void i2c_init_board(void) #endif } +#if defined(CONFIG_ENV_IS_IN_MMC) && defined(CONFIG_ENV_IS_IN_FAT) +enum env_location env_get_location(enum env_operation op, int prio) +{ + switch (prio) { + case 0: + return ENVL_FAT; + + case 1: + return ENVL_MMC; + + default: + return ENVL_UNKNOWN; + } +} +#endif + /* add board specific code here */ int board_init(void) { From patchwork Tue Nov 28 10:24:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 119830 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2915940edl; Tue, 28 Nov 2017 02:35:00 -0800 (PST) X-Google-Smtp-Source: AGs4zMYIEiyg4+tEtus0Mfuw13oVW1Dqh18PrUsN7xOJNkghRP/dnSMQRasAALZEjTGp/fBWtqii X-Received: by 10.80.216.202 with SMTP id y10mr1967895edj.221.1511865300516; Tue, 28 Nov 2017 02:35:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511865300; cv=none; d=google.com; s=arc-20160816; b=ONur900HcCpqAPdksKaXHb0lkjbK9mmUx9w+P4UZWJNEK92lN3MEM5dEbR1WjeYrya RSkMxuHyQnekzEB2ro7dclDnS9M+nMy4+0elNMq+4xrHH/tdSFd+6Bbz+SlVDP4MM8Fe hvAszxyxtFEJGMFc4XNVjMeJa6NMlxoWIaxB2ueHuczq+3Vx7tnUDE52gbTnAQk3wy/g BREi7wq2Bck90a92851SBPIXQZeQI/XroqWmD3pYXQVHhcTqS/A8zpmaTxeh+TsWTC1e hs8BORfKSk0UCRLymaoHxneY689L4rKRq1+0dbrzoGc1D/F1Vuz/E+b7pOsJuBqcSXRG q4xQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:references :in-reply-to:message-id:date:to:from:arc-authentication-results; bh=yYhxWeV6HH5aX/v8w0YeWXdRB+gxGlnS+mQeFxSPTNU=; b=VFT9LFIf56rFd+ym9aCDt7fhvFOdg9dMo8YU17+huoqOtdkKWnn6HrcvkMWksgD1rY NDCYXW7sOagp68TknkvyHACRMGhvusb1nVLf4qgCRxpgIVXLzzaQnOquTb/JRGtRi3Q4 e6DJUpNgci0NCLkvgBufNPCUDzPfbjCaFoNMzuFcKigqmuoQOjTCRwRfIkmge929kt1E 1G9ZVXUbag6meCdZFdLmWB9ufO6iFem8ulrx8nITqXqY1CQ507oigvuDo8pyX55ia4Nl neDK6uuYdehR/Fxtk/0+Ml1uWF1mIfRsVlkXco0GRpoFDBI9LiFlgdlVx3XU+EMWAfUW zcog== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id b22si357927edj.335.2017.11.28.02.35.00; Tue, 28 Nov 2017 02:35:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 1BB07C21E5D; Tue, 28 Nov 2017 10:29:11 +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=0.0 required=5.0 tests=none 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 2A744C21DF0; Tue, 28 Nov 2017 10:25:41 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 6A8C4C21E8B; Tue, 28 Nov 2017 10:25:03 +0000 (UTC) Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id AE360C21E2F for ; Tue, 28 Nov 2017 10:24:57 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 0D2E420856; Tue, 28 Nov 2017 11:24:57 +0100 (CET) Received: from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id D3EB120380; Tue, 28 Nov 2017 11:24:56 +0100 (CET) From: Maxime Ripard To: Tom Rini Date: Tue, 28 Nov 2017 11:24:49 +0100 Message-Id: <182f5231f9319f8a2b34f3c4ba743f370d2934ef.1511864667.git-series.maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: References: In-Reply-To: References: Cc: Thomas Petazzoni , u-boot@lists.denx.de, Andre Przywara , agraf@suse.de, Maxime Ripard , Jagan Teki Subject: [U-Boot] [PATCH 14/14] env: sunxi: Enable FAT-based environment support by default 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Now that we have everything in place to implement the transition scheme, let's enable it by default. Reviewed-by: Lukasz Majewski Signed-off-by: Maxime Ripard Reviewed-by: Andre Przywara --- env/Kconfig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/env/Kconfig b/env/Kconfig index bf6eab6b4ace..19524638e6e1 100644 --- a/env/Kconfig +++ b/env/Kconfig @@ -55,6 +55,7 @@ config ENV_IS_IN_FAT bool "Environment is in a FAT filesystem" depends on !CHAIN_OF_TRUST default y if ARCH_BCM283X + default y if ARCH_SUNXI default y if MMC_OMAP_HS && TI_COMMON_CMD_OPTIONS select FAT_WRITE help @@ -370,6 +371,7 @@ config ENV_AES config ENV_FAT_INTERFACE string "Name of the block device for the environment" depends on ENV_IS_IN_FAT + default "mmc" if ARCH_SUNXI default "mmc" if TI_COMMON_CMD_OPTIONS || ARCH_ZYNQMP || ARCH_AT91 help Define this to a string that is the name of the block device. @@ -379,6 +381,8 @@ config ENV_FAT_DEVICE_AND_PART depends on ENV_IS_IN_FAT default "0:1" if TI_COMMON_CMD_OPTIONS default "0:auto" if ARCH_ZYNQMP + default "0:auto" if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA = -1 + default "1:auto" if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA != -1 default "0" if ARCH_AT91 help Define this to a string to specify the partition of the device. It can