From patchwork Thu Nov 16 09:22:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 119031 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5360113qgn; Thu, 16 Nov 2017 01:27:31 -0800 (PST) X-Google-Smtp-Source: AGs4zMa/AM8e1f+he06s0UeZfx7VxSE9HAavL/x+/rIOy4zmxpmhe3RuwzMlG2foGEgT4rAblP00 X-Received: by 10.80.166.196 with SMTP id f4mr1849040edc.278.1510824451082; Thu, 16 Nov 2017 01:27:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510824451; cv=none; d=google.com; s=arc-20160816; b=MJmSaJA41JjeTKUy6MYNMaRMyiExPxpLQh8HedcO6F0yjFFTlonSl3W49+g7lpMyYF w67I97TTeGE9wnF4p1vrJqUFEeF4qEaNWyiDIvGVX9pDB7aq1EVUPlJ/pKbiCIQ9icIe ZTaXmD59ap5c0hZzOdzVNlP4nv2QLvzfLcMfXwPkiyQxLPRitU/Ozd7qvYO3n9j78zEV 9LI4195V37Ytd8EhUOQ9SDqQx8phaupqmLX7yFFTGD/DRcR+CXJ1Hiqgnts5H/wOPjsX GCy9bFJbhK1rpaExHdZsTl6vICFkqT32u4Qy3fLWh8MCDX6GJ/t0Css0c+ZASA3sbQB8 xszg== 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:message-id :date:to:from:arc-authentication-results; bh=RHvP45mXGP+Yz8WIWvHRbQfIY1SgK0WQjw646HJDNqk=; b=RhDwnp1NRWsvTq4nvIXY5UL9SIsBNHxfugHuWA9CzNxq2avhUhBbZb0IW8Gx7Ddb+R ttL6Nu778ea/me97R6FiLSixuGDsZP2noGg4O1dRG74zCuc10mX07zbg61k0lxo6cshP 6tIlXiuCNYRMpgwYVxOmKRzgKULQMzUMAJgOsOfXH8DhrH3hefrD7iP+uOKSjFvW6Gij FQ/GaUmPwxibfLVsKcwoyQnHpM8WylH8iHu3fxyK9n/OF8GanjNiWrAcMhV/jFKdph/B 5BiPRfE0txAHDxPp4GQPHQn2MUMPyBu104JFR9zDu4yPheooMAwuidnBEvjZ2BP386ou LGRA== 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 e32si871638edd.76.2017.11.16.01.27.30; Thu, 16 Nov 2017 01:27: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 9A468C21DF3; Thu, 16 Nov 2017 09:23: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 33383C21DB2; Thu, 16 Nov 2017 09:22:51 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E51A9C21D80; Thu, 16 Nov 2017 09:22:47 +0000 (UTC) Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id 790D4C21D6A for ; Thu, 16 Nov 2017 09:22:47 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 704F0213E3; Thu, 16 Nov 2017 10:22:46 +0100 (CET) Received: from localhost (unknown [185.94.189.187]) by mail.free-electrons.com (Postfix) with ESMTPSA id 2963E2055E; Thu, 16 Nov 2017 10:22:36 +0100 (CET) From: Maxime Ripard To: Tom Rini Date: Thu, 16 Nov 2017 10:22:22 +0100 Message-Id: <20171116092231.27740-2-maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171116092231.27740-1-maxime.ripard@free-electrons.com> References: <20171116092231.27740-1-maxime.ripard@free-electrons.com> Cc: Andre Przywara , agraf@suse.de, u-boot@lists.denx.de, Maxime Ripard , Jagan Teki Subject: [U-Boot] [RFC PATCH 01/10] 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. Signed-off-by: Maxime Ripard Reviewed-by: Lukasz Majewski --- cmd/nvedit.c | 4 ---- env/env.c | 2 ++ 2 files changed, 2 insertions(+), 4 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..84c12e27bc3f 100644 --- a/env/env.c +++ b/env/env.c @@ -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__, From patchwork Thu Nov 16 09:22:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 119034 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5361589qgn; Thu, 16 Nov 2017 01:29:23 -0800 (PST) X-Google-Smtp-Source: AGs4zMbMB8+llmIzHx5SD4q6m8885f8fZhIFeZarFBBy4HI5+AZ2S10axflUyQSZ++mnaznHj50D X-Received: by 10.80.164.209 with SMTP id x17mr1820725edb.158.1510824563070; Thu, 16 Nov 2017 01:29:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510824563; cv=none; d=google.com; s=arc-20160816; b=uYfA6xrsuDirFLA1OBfQQ7UHe3AeoL7QVemKjdoz9YMM5BMktuNBEHk55YBVVzPGQO ujlX2olxXPIS3x/+gbqCBzgHDfZExIQfTtp0syp52/LfhB5g75FdmKnxAyNXoms0YO1l qON0ReuYBpjwhxxDu9qTHbwsc/JKlqUblkn6Jinpj8q3NVqZR6L2pyecCvQCnnevKhPi K9gjS9H2ZakwOJ76mUZCGgXHf5rua8DgrftdZAPnUesT6EuMNwmg1rT/0kJd8KBX4JMy QmbFOL3VW2h28tC+4hiiq12KK+0mAhK9XvIbSyL5fvZiUhmCgw289t4BRla2M2GXQm2d IUNw== 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:message-id :date:to:from:arc-authentication-results; bh=8d4TiVTnOz8BYMQZiZtTKQ8DwKRrt5W1trQ3XStP5UQ=; b=EfY4JKUKkYLhLhvHcx3WQI8us6Qtt1N+Ftds0TfWJILFvJCC3g9RxiBvW7A6vHsliX mTUenv8rDqKBuzYheSAfHssHyd9HC7+v7hcDHQoZQc4dWnhXNYEq5UNs1X0wGUMqf+w0 8NVTPrLH8js4BUiJ3nWpQtUzqzHyEftEpGo7hTTds62Nh6F+PUREw54XacHQ+l8kZ9O2 TIMqi3mtl8AizPfYQpCZMZRv1soVI8x5HStZl1Nhxlmy+qC3Hsa7lXiZCciC6qHP0byu IQRpZBlRPD8E/DUIOqk0/HFM8STsqS46nhTelmrVIV7PzZ9FuWmKWyFOj0ngO7k+MNdq 4+hQ== 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 j3si818840edb.372.2017.11.16.01.29.22; Thu, 16 Nov 2017 01:29: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 A3E30C21DD7; Thu, 16 Nov 2017 09:23: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=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 1311CC21DA0; Thu, 16 Nov 2017 09:23:08 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id B5E28C21D7E; Thu, 16 Nov 2017 09:22:51 +0000 (UTC) Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id 7944BC21D80 for ; Thu, 16 Nov 2017 09:22:48 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 66E7F2055E; Thu, 16 Nov 2017 10:22:47 +0100 (CET) Received: from localhost (unknown [185.94.189.187]) by mail.free-electrons.com (Postfix) with ESMTPSA id 1ABA82093B; Thu, 16 Nov 2017 10:22:37 +0100 (CET) From: Maxime Ripard To: Tom Rini Date: Thu, 16 Nov 2017 10:22:23 +0100 Message-Id: <20171116092231.27740-3-maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171116092231.27740-1-maxime.ripard@free-electrons.com> References: <20171116092231.27740-1-maxime.ripard@free-electrons.com> Cc: Andre Przywara , agraf@suse.de, u-boot@lists.denx.de, Maxime Ripard , Jagan Teki Subject: [U-Boot] [RFC PATCH 02/10] env: Make env_driver_lookup_default private 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" No that there's no users of env_driver_lookup_default outside of env/env.c, we can mark that function static and remove it from the environment header. Signed-off-by: Maxime Ripard Reviewed-by: Lukasz Majewski --- env/env.c | 2 +- include/environment.h | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/env/env.c b/env/env.c index 84c12e27bc3f..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; diff --git a/include/environment.h b/include/environment.h index 7b9821638960..226e3ef2d23a 100644 --- a/include/environment.h +++ b/include/environment.h @@ -302,13 +302,6 @@ int env_export(env_t *env_out); 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 * From patchwork Thu Nov 16 09:22:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 119028 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5359098qgn; Thu, 16 Nov 2017 01:26:09 -0800 (PST) X-Google-Smtp-Source: AGs4zMZie5BT+2PCpmy+OOiPA1R1XonHKSZ+BTmB7XC47plJ47i32IEGZGncLKFYiBTiixvsAP/g X-Received: by 10.80.173.88 with SMTP id z24mr1409766edc.133.1510824369314; Thu, 16 Nov 2017 01:26:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510824369; cv=none; d=google.com; s=arc-20160816; b=Eo7QbAxnXHUEO1nCOGHbstcFOTt8xYW/doACR4UcqRCG3R3Q3OhOgRNuyUP05TqKBz hOE0W35SrdUPT6s5imDIu+FDKqRGZkwsbcTYHtd8yaIQeJcmfsHwu1wy+1GT7GwqVIuq 3/GhQFAenY9c+7iaYZ/D+Ml0AAEFjCOxeONgU5oT1NrmODqkaguYURyFOpWu9jTq5uWm LOff3G95+AW7sHBqzaiZtlX2NFN8u1BTCBpiW4ALdCG7lm45ZjRgjfAxeEuKOSpF6AfR XEmPJopG0Ag0yN9daEEfFLg0ZlQtySeDsJrG4wRnQmnlYbewYe0m7C1/PxLg/Co+BDs+ eAPQ== 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:message-id :date:to:from:arc-authentication-results; bh=BD3V/Zd4cSuhsMe6/Pt4Vng/TBWgWvy7DbA9a5CgMwg=; b=EQNFxHgR1xXNpQeN+Qiv0KTKiu9C3quifpnbgPT5nzX4g2q0Sy4JPEcEKEAwJAdw/v v22+SSxJyT+Sr3lITTDVqLGTKOnzwjcvhzsYJwMd7jiiAra2+4nM6k6eoePOJKzOCX94 EPjdh181UvCFddn8HIAoFcofP4T6q3oFosudht3aAeipTUki4/4UB9k1hwnySSFmsQlR VR4xQdHiXAllZJAZDT34bT8V91CIN8/6sUUqYI5v49ikWaGt0wTslO9dHitASMa447fJ t8OVujHVXWPTpyUXlmXHlKYRbckvB5/kka0niUnDSta9KCWpM/6rUCkBeO+OU/F1qT/s 6FGA== 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 n88si828197edc.498.2017.11.16.01.26.09; Thu, 16 Nov 2017 01: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 EB105C21DDA; Thu, 16 Nov 2017 09:23:59 +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 89289C21D90; Thu, 16 Nov 2017 09:23:12 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 9A03FC21D8D; Thu, 16 Nov 2017 09:22: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 76AFEC21D99 for ; Thu, 16 Nov 2017 09:22:49 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 694162093B; Thu, 16 Nov 2017 10:22:48 +0100 (CET) Received: from localhost (unknown [185.94.189.187]) by mail.free-electrons.com (Postfix) with ESMTPSA id 1650D20DD4; Thu, 16 Nov 2017 10:22:38 +0100 (CET) From: Maxime Ripard To: Tom Rini Date: Thu, 16 Nov 2017 10:22:24 +0100 Message-Id: <20171116092231.27740-4-maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171116092231.27740-1-maxime.ripard@free-electrons.com> References: <20171116092231.27740-1-maxime.ripard@free-electrons.com> Cc: Andre Przywara , agraf@suse.de, u-boot@lists.denx.de, Maxime Ripard , Jagan Teki Subject: [U-Boot] [RFC PATCH 03/10] 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. Signed-off-by: Maxime Ripard Reviewed-by: Lukasz Majewski --- 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 Thu Nov 16 09:22:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 119030 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5359725qgn; Thu, 16 Nov 2017 01:26:59 -0800 (PST) X-Google-Smtp-Source: AGs4zMbTviniNkXe/l8Ck8f9bMvyEJZoQfZ1jKsDpTo55N2yQ8ANJ/cMghWe0UYRUflLMcPHmpST X-Received: by 10.80.241.72 with SMTP id z8mr1862153edl.35.1510824419005; Thu, 16 Nov 2017 01:26:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510824419; cv=none; d=google.com; s=arc-20160816; b=kx1Kydm5Ikga4c64AJHPANLuTT4ZPeumKGGuvdGuGczDxEm+QdYa4BHAdAr9xWcFZ+ 8MnmnNcRpsnwMEkNkjCOhucwKoFBkOPaTJM9dgGgHAZWve6DtTdqCOxOBZQmAjSHRDe+ dC8VQwfp3H274GyUze4WGo3j6aTWnu746PB/klhdJHpi0fDNgvhH9mbqtX0IY7SW4q+Q zaWtMpSixzTOs24vnOfTCxK9eX1jE9h7380eT+K+grdbvGwaFN+dFN1Ewp0q66eMtdAd tvsBTzti++DGhkj2evs87x+zMqc2U3+5aL9sMOrdcU2M1qSjn+odb/6JmQgTQl6fPE8E B4+Q== 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:message-id :date:to:from:arc-authentication-results; bh=m1itz6NXCvi38uV4xomobqx3upqwFgOJJcvesTMGUvI=; b=WJXG2ma7ImxdWoifE7vp4Ca9xyI6ORVxycKV/UQFYg2EKTaN+VOiMtwhvATCEE9Epb 6UKfAda6PihV9zva7kCJ06dXV3ISJNeabijqVfUZ+FIDEYpdkn8JHY/xpItBDh8d6J9X +xv4udVHMTmRZdkKCsFUeMC2kWHrmX9qP9UBItTUgTD963zOpX49jaS4MzPZEPoRN9Ly e4X422SZIppBOuKeFOMsX7J0knwGMGOeVL+Esw9S2+65vNuleumG46FDP8xBCejPHt42 FjsuJGoeiQ+480824zuSQZoaelAabfdFfqkD/eHDOkoyf38+1NEsr0EiVKa4lxumW/2F G1og== 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 y19si746450edb.258.2017.11.16.01.26.58; Thu, 16 Nov 2017 01:26:58 -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 97D40C21D7C; Thu, 16 Nov 2017 09:24:17 +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 40F10C21DA2; Thu, 16 Nov 2017 09:23:53 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id B7AAEC21D80; Thu, 16 Nov 2017 09:22: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 8E59DC21DDB for ; Thu, 16 Nov 2017 09:22:55 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 87151203AF; Thu, 16 Nov 2017 10:22:54 +0100 (CET) Received: from localhost (unknown [185.94.189.187]) by mail.free-electrons.com (Postfix) with ESMTPSA id 0247020DD6; Thu, 16 Nov 2017 10:22:38 +0100 (CET) From: Maxime Ripard To: Tom Rini Date: Thu, 16 Nov 2017 10:22:25 +0100 Message-Id: <20171116092231.27740-5-maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171116092231.27740-1-maxime.ripard@free-electrons.com> References: <20171116092231.27740-1-maxime.ripard@free-electrons.com> Cc: Andre Przywara , agraf@suse.de, u-boot@lists.denx.de, Maxime Ripard , Jagan Teki Subject: [U-Boot] [RFC PATCH 04/10] 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 Thu Nov 16 09:22:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 119032 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5360631qgn; Thu, 16 Nov 2017 01:28:09 -0800 (PST) X-Google-Smtp-Source: AGs4zMZBct40Hr+P7LgQYuiCg99hyeVsk6tdkG5bLqsYqkUWHFX0VDZO8H+B1geQ0b3x1doqZ35/ X-Received: by 10.80.191.15 with SMTP id f15mr1847247edk.82.1510824489365; Thu, 16 Nov 2017 01:28:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510824489; cv=none; d=google.com; s=arc-20160816; b=rdH/J2yPYUb1LwbLpOsYzJEaYJVO2b1L/VQIUOKdDivPWn014Eur3C5OXzU2xcztF8 Tx/2JcVUscE15V+uKuNYq6y4vTHL9N5oLDvDMlmszDhksfYYuPsvkoFFX8IcoKq+3Bri ZCK8qHc9mGKwqx5iW1aaD/Swd12XyHhpx66WfAbyIynkwtdbiyVweAU1VnHiA67m1PDG +Yinpw84GnPWxr/FoKuiFcyfndgHzC+D6sHv+GujdbDNXUrfcaMnO4UeGh7vjvhglodl iwK0IFn9apmxhOqY0OKzKGoE+fcQ5yPEYQOwlBvwf/bLwMME5hVrnVI0gNpQ1dFeOm9u C8pw== 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:message-id :date:to:from:arc-authentication-results; bh=FXHLx0bz2Rn82z5Ic61FG5lNWLSyWXsV8Hy5KMLY/+w=; b=FeJT2hFXGlTqeeLKdxsgZWDk+QAMph3csb2NrUOy2AzRZpKinr3QosZKTdi1jx/epw 2P+ppqMvmV5FpguEcd9OpAy9R+2ltilZYNruwMP4aFrRl/CwntGOlxJcQ6sDrlHM8MF9 qnSNeNGeD+PRd5v8UdPDzU/3w1QC+kSlyhBpYyGRh5kQHWgN/0oiiy3+LvLrNxxtQ6Wl fX5opetccNib/e05r/zBtwdj2BOCR9mbJMTFUGJpPmSn+KbY/1UNOMl17CCQB1JVBQhI ntX2Dwc97+PyS4qmtzKnJee5ys/rgRvuROuTybhyhRoa66T0uBLMTHTA/ix4txggp7fc E8JA== 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 k60si840954edc.530.2017.11.16.01.28.09; Thu, 16 Nov 2017 01:28: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 E5D00C21DA0; Thu, 16 Nov 2017 09:24: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 4BA3FC21DC5; Thu, 16 Nov 2017 09:24:06 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 74753C21DC5; Thu, 16 Nov 2017 09:22: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 90F9DC21DDD for ; Thu, 16 Nov 2017 09:22:55 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 863642055E; Thu, 16 Nov 2017 10:22:54 +0100 (CET) Received: from localhost (unknown [185.94.189.187]) by mail.free-electrons.com (Postfix) with ESMTPSA id DE12420DDE; Thu, 16 Nov 2017 10:22:39 +0100 (CET) From: Maxime Ripard To: Tom Rini Date: Thu, 16 Nov 2017 10:22:26 +0100 Message-Id: <20171116092231.27740-6-maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171116092231.27740-1-maxime.ripard@free-electrons.com> References: <20171116092231.27740-1-maxime.ripard@free-electrons.com> Cc: Andre Przywara , agraf@suse.de, u-boot@lists.denx.de, Maxime Ripard , Jagan Teki Subject: [U-Boot] [RFC PATCH 05/10] 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. Signed-off-by: Maxime Ripard Reviewed-by: Lukasz Majewski --- 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 Thu Nov 16 09:22:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 119029 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5359512qgn; Thu, 16 Nov 2017 01:26:41 -0800 (PST) X-Google-Smtp-Source: AGs4zMb28Y3Fr9xXLb8977JTEKPF3MkkZnu2NcvRyuGzQQhhASl+CubyFOnCNeIUo2jHxqAYPMME X-Received: by 10.80.174.2 with SMTP id c2mr1789553edd.247.1510824401283; Thu, 16 Nov 2017 01:26:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510824401; cv=none; d=google.com; s=arc-20160816; b=m2A1RXmW9kxIPQf0I1G0sEp6Pzi47GeSPIP0RfyrwGfCz0vCrAmLJVDXCFmtNrfZcm 9lPY3DaOIoWgGY09cEIGsds7sWgnGzzwTWS16qeiZQq2wXRZk4XJk7iqI6iNgxNeB70H E06mdElI0R40asv8+hJk6iqK8twlyrRt4fPY2DHQZq2u3sAPCrcnRCoIPJknWxF5ADUj ZwMG1ZkuEqWgdKrESZQ97zy+2OOJqtUyC9d/RKVcQJc9TrntE+SHmWn8jgDU9saShYre zhK4SH5Lg7MXfBgZWKEVParbtYrn1b8JVqEcdDUd4AcHL1RtP/QpU+O/fbOAHlLWSCEB cKvw== 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:message-id :date:to:from:arc-authentication-results; bh=sCc7bTFAtpkLOXzTPuLNuFOsyssOkd5R2NblMgbHm/E=; b=WeaShMlDb2kix0WnZe4qVf2gQyf3Rkgt/tHL/hL+TrSOoJ+DXn9W193WC0pOQwxBlf 4d0cGsc1kigvfRY0Beb6y+pUrLc2gHjHBfyquhMdMgfZaE0etz6z08cheC1TjVOUpEuB zmmVH5Dptu7AbXE4Nw/0+fS0VpWw8HHsXmtkXFieVUpS6uIz5qEttp2X8woKIVMKVq3z qVkLt3xZie8ln+6iUDo4cZJGh8HfSa9lFqVQ6pgfsVU+v1f6ZRsQ56Y37hnGkyv/1qCF jybytYcoON2yLhUcyE/FEnVMhaTKGqgzq+JCZ+sIdubrtBE6u1Ps302Tr1YsBfdPdNM4 4FIQ== 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 r49si862787edr.204.2017.11.16.01.26.41; Thu, 16 Nov 2017 01:26:41 -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 E0280C21DCE; Thu, 16 Nov 2017 09:25:30 +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 A713FC21DAB; Thu, 16 Nov 2017 09:24:25 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 41DFEC21DDF; Thu, 16 Nov 2017 09:23: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 B1996C21DBA for ; Thu, 16 Nov 2017 09:22:56 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id A2FFA20DD4; Thu, 16 Nov 2017 10:22:55 +0100 (CET) Received: from localhost (unknown [185.94.189.187]) by mail.free-electrons.com (Postfix) with ESMTPSA id D4F6B213DA; Thu, 16 Nov 2017 10:22:40 +0100 (CET) From: Maxime Ripard To: Tom Rini Date: Thu, 16 Nov 2017 10:22:27 +0100 Message-Id: <20171116092231.27740-7-maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171116092231.27740-1-maxime.ripard@free-electrons.com> References: <20171116092231.27740-1-maxime.ripard@free-electrons.com> Cc: Andre Przywara , agraf@suse.de, u-boot@lists.denx.de, Maxime Ripard , Jagan Teki Subject: [U-Boot] [RFC PATCH 06/10] 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 --- env/env.c | 75 ++++++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 50 insertions(+), 25 deletions(-) diff --git a/env/env.c b/env/env.c index 1d13220aa79b..6af9f897b0ae 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 Thu Nov 16 09:22:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 119036 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5362838qgn; Thu, 16 Nov 2017 01:30:43 -0800 (PST) X-Google-Smtp-Source: AGs4zMbTNGzG0ehwKjisuFHDcCI24BqDzejnOiFHSB5B/VlY7YwHTHDlpUBl+zxR1ACgEqUF5qW+ X-Received: by 10.80.208.10 with SMTP id j10mr1819887edf.194.1510824643515; Thu, 16 Nov 2017 01:30:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510824643; cv=none; d=google.com; s=arc-20160816; b=OtMm6Ntt6TGWCBKfGHI/i5xkh1u3Gm1rHZOxzwSrePTYSdoq93JVRLXDjcwVpe2cb7 k22zGoNAos4R3I/Ca31pMWvcULn70dslPVs2w7F/QkAxasCmxK5OULR3BqBq3ffPYu7D bTE/q4KODpwJYD2KZEosMer6vcNRlrNWXHvoUX6rPWb+KWNhC6uxNhG0oZtf6Ta+prg7 RN/JSKBuXaxxe2YftkWuQ3RZx2IW3Kxx99WjiRSfti1zQO3XRCO7GASKAPmeS7L2OALC Fc3SHIb7kF+hh+xATznuVl6Fvo2s529Dq/k4vBCuvKXsj0Fj+0gnQaCNNkFX3RZJrQy7 1mbA== 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:message-id :date:to:from:arc-authentication-results; bh=+suBh+qxF0EOEK/EJbQJPmtF7Q7BywzQ8BNHhJRMTIc=; b=X624Xy9txmirywvBi2JoH3kZ0Qu+fppItFHhClCqHmAjNywdz9W4sm/sGlJnG+9gR6 HUahctgxJ51fnsPWjVpYqF9a88DxNcekp2Tj0dQXtz8sZbI+e1opZ8B7g5jWEXRySmAb CWRErvI68FJgTvzNwmR2SxRU3LZTkhMZHFYFcqdNqp4MQ7TDscSQJMF6UxIs9nrMZhTm nJ4PIbrHCX3Bqv1D4XmR14aTZf4ewqjTGwEIGGV4trlIPfDFu7U91xwZwXHGrtiL5oL+ u2n41qshtzVxv2ryIw2dipACnTZFDLZBMqR6iLxUw1YDmdyJ+3YAGZ0h5EjLk4wJXGLz nWmA== 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 z5si877206edj.28.2017.11.16.01.30.43; Thu, 16 Nov 2017 01:30:43 -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 EA01AC21DA0; Thu, 16 Nov 2017 09:25:12 +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 4ABAFC21D7B; Thu, 16 Nov 2017 09:24:09 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id CC96DC21D7E; Thu, 16 Nov 2017 09:23: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 90390C21D88 for ; Thu, 16 Nov 2017 09:22:57 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 8A35F20DDE; Thu, 16 Nov 2017 10:22:56 +0100 (CET) Received: from localhost (unknown [185.94.189.187]) by mail.free-electrons.com (Postfix) with ESMTPSA id CA70F213DC; Thu, 16 Nov 2017 10:22:41 +0100 (CET) From: Maxime Ripard To: Tom Rini Date: Thu, 16 Nov 2017 10:22:28 +0100 Message-Id: <20171116092231.27740-8-maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171116092231.27740-1-maxime.ripard@free-electrons.com> References: <20171116092231.27740-1-maxime.ripard@free-electrons.com> Cc: Andre Przywara , agraf@suse.de, u-boot@lists.denx.de, Maxime Ripard , Jagan Teki Subject: [U-Boot] [RFC PATCH 07/10] 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. Signed-off-by: Maxime Ripard Reviewed-by: Lukasz Majewski --- 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 Thu Nov 16 09:22:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 119033 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5360958qgn; Thu, 16 Nov 2017 01:28:35 -0800 (PST) X-Google-Smtp-Source: AGs4zMbwKe18WFyQNiUEtpGA2XFGluq0yNlev1knFq5uYs3VL+9LXy8boFpdUMYBfeX/vbN6IdeS X-Received: by 10.80.157.141 with SMTP id w13mr1906568ede.151.1510824514932; Thu, 16 Nov 2017 01:28:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510824514; cv=none; d=google.com; s=arc-20160816; b=LLMsLdBywwguKlVd71GEvX/EV57SWGNXOKregrGJaVjE0gNohLxCyugfhrD6uh8MDu LUgAeTBc6N2V43ZbsTteh8pjoQoYL58wQxuWetcoih7q3xGX93bx3GCjllc35jDo2fw1 LN37iIZt0W7MCTDl1g2X+G+8Jc/HECyDftV+4ie41NtfrdPP7H6Xnz7dZfzqVLd6PxL2 jL6Bdp/jg3kKLt3FyX8itYmnnhZm59QLjYIAq5WlpHoGLe79l3lriKFHczLYtWweq1P5 Ygw/Ic+hH+nBhRr6UFneNHOUU1N2mnPl+TYpRPeGpJV0Osddy1QKm3I8hpZo6AX7utJ8 Tufg== 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:message-id :date:to:from:arc-authentication-results; bh=OfkhBYnvI1YwVWWSYf6py2O7MbMuOlxDSyGnVosdEvw=; b=I+F5Eg59dQebez9sYMV0UlyRd6idUCIVi3a/Mqan7V7hGUDpIJPpsXK78hyZr61oKA ak1Jd25nhmrt/jjJLR50zgbCOT8RZKGVy9mmKoaT3Fcd+fQrdzrX12MV1DWdu5KzI5nY skD9Bs+17xXPUBBWVy4Xpum0Cv6TjbBEo8XHbbIZbdCg4TgbCRoOwpZKhzSl5Qo37Tod GqtR301yC597MMCM+/YEfEedmW+QWudmWetQ/JvXQHj20D9LrSGm6Ks9RX/vk4aYUj+g DtPjLO1unvYg8Kx6PZhwrXP7dNugS1aZnOkEFtwaPaTptp6mveNR8gQ17oJ0MSDz8NcC o3Kg== 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 w1si847416edk.103.2017.11.16.01.28.34; Thu, 16 Nov 2017 01:28: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 64157C21DC1; Thu, 16 Nov 2017 09:25:47 +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 E3040C21DE9; Thu, 16 Nov 2017 09:24:27 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id CDE1FC21DCE; Thu, 16 Nov 2017 09:23: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 943C1C21DAB for ; Thu, 16 Nov 2017 09:22:57 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 8B6DD2093B; Thu, 16 Nov 2017 10:22:56 +0100 (CET) Received: from localhost (unknown [185.94.189.187]) by mail.free-electrons.com (Postfix) with ESMTPSA id C0AA9213DD; Thu, 16 Nov 2017 10:22:42 +0100 (CET) From: Maxime Ripard To: Tom Rini Date: Thu, 16 Nov 2017 10:22:29 +0100 Message-Id: <20171116092231.27740-9-maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171116092231.27740-1-maxime.ripard@free-electrons.com> References: <20171116092231.27740-1-maxime.ripard@free-electrons.com> Cc: Andre Przywara , agraf@suse.de, u-boot@lists.denx.de, Maxime Ripard , Jagan Teki Subject: [U-Boot] [RFC PATCH 08/10] 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. Signed-off-by: Maxime Ripard Reviewed-by: Lukasz Majewski --- env/env.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/env/env.c b/env/env.c index 6af9f897b0ae..aceb77d4073c 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 Thu Nov 16 09:22:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 119035 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5362156qgn; Thu, 16 Nov 2017 01:30:05 -0800 (PST) X-Google-Smtp-Source: AGs4zMakhyovDkf9hjFnYQLOIzebHkQsODEDkmvlPz2ixtLccuaC/CcjXGyk4LgEDtJSRGSKltrw X-Received: by 10.80.175.66 with SMTP id g60mr1857837edd.283.1510824604992; Thu, 16 Nov 2017 01:30:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510824604; cv=none; d=google.com; s=arc-20160816; b=iOhrLjYH7OP5+/hCjTACy7xceSKIAV9G4pFFDe755lSEEsPoXM+ZLngrVffNvSZIl4 Z43DnTvuwxmzhmWjCuMz4103zo+hqOufDjXU0CQ24aByXIOJtwvsqPs46ttxmX13qZcw hsPSfWa2AYBUNhYwyx/2odPJuCXpvP5f3dH9aZjYUl3de559szp4pi4Y3VcTrR2NFLAq X+Qd46TDqKj9exh8z3/HkByYjMYSh3WbqBzGzrTKDSk+aZkCzzsf/oqENtzJDJ5hETkw 78JUC/TFVIw6IH+QVAuPW7ubCSmhIvbEYRR+58d/5+pm7Ft4eigEZcrl3EvAeVX6SLk0 85Jw== 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:message-id :date:to:from:arc-authentication-results; bh=EIY6UXHb7P0716r9C1bVqnldv/BufKTmWozplDUmXnQ=; b=y4RZ51OYXpF3M+rkCgN6ROexx3BLB4C9jYK2nt6NPPIbCKUhK2X1MClrGueHKOLhPY jmMWir7gRgUgK6VCwBrKIZqTS9+Tz93dIFPypyzcvFBLviCDqkXI0kd6DDocX3S4wZ/4 sm9hxasPPyPYNtuigMYIIe1rDYiNenCQ/peoDTmKsFFwOZae0dwaAO01oXRvkXk40vXS sV09JMip6dt37bjkhGQy9zkBWkGPWS0i9xDwVwdtI49XQu6p3dWeOzVl1sCg2IEbwD/B tIdVTZsQfJtpVyQIl+6pdrVC8tfjjnfjYxbCUNk92D9LVL2b1k2Lwj2yLBQz/qoDzgFs ytDg== 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 y8si866144edk.42.2017.11.16.01.30.04; Thu, 16 Nov 2017 01:30:04 -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 88018C21DDE; Thu, 16 Nov 2017 09:24:54 +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 BFEFCC21DA1; Thu, 16 Nov 2017 09:24:07 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id AE10AC21DA1; Thu, 16 Nov 2017 09:23: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 89D3DC21DC6 for ; Thu, 16 Nov 2017 09:22:58 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 7D51B20DD6; Thu, 16 Nov 2017 10:22:57 +0100 (CET) Received: from localhost (unknown [185.94.189.187]) by mail.free-electrons.com (Postfix) with ESMTPSA id B206D213DE; Thu, 16 Nov 2017 10:22:43 +0100 (CET) From: Maxime Ripard To: Tom Rini Date: Thu, 16 Nov 2017 10:22:30 +0100 Message-Id: <20171116092231.27740-10-maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171116092231.27740-1-maxime.ripard@free-electrons.com> References: <20171116092231.27740-1-maxime.ripard@free-electrons.com> Cc: Andre Przywara , agraf@suse.de, u-boot@lists.denx.de, Maxime Ripard , Jagan Teki Subject: [U-Boot] [RFC PATCH 09/10] 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. Signed-off-by: Maxime Ripard Reviewed-by: Lukasz Majewski --- 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 Thu Nov 16 09:22:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 119027 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5357737qgn; Thu, 16 Nov 2017 01:24:16 -0800 (PST) X-Google-Smtp-Source: AGs4zMZl8/8yFRlRNzEYV35VjjYeYzVndtb6C0p2dh9Twbpnh24Tye/brUxqHjqaeZf/vpLRUECr X-Received: by 10.80.153.13 with SMTP id k13mr446218edb.208.1510824256758; Thu, 16 Nov 2017 01:24:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510824256; cv=none; d=google.com; s=arc-20160816; b=MA+C0YBVHiXrFhL3r5pEFTK3OuExwie9dnmrCVZqoijeLH7KdiHjol5ywmxG+oBzRI kxiadyvjQXMYUswa9GaEl+vt7xfdKHC+SkPqVoTnHCSukIpZFeGX6e7xr5ClG3B+6sYI yavfCuiPPiLTrgFONowkGo6oAn82KP3svTBhj64CmS0d6UbRjx+unJ+7cNsZ8ojzJoGL 8i5ZPZ5DDvRwdMk1JQ2Gl7c2M1RBVsuPm/yDacXWDL6zD7Ndi1f0nAgEbQ/BoqIokgGn prF3R+reduoxGMJiIg01+PQ21F4tm6Sc8ZU1e3NHRk3tAzgLjdE0Xzmd3/jfcNib0jxM Q1Kg== 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:message-id :date:to:from:arc-authentication-results; bh=7fbkXbpYLmdDj6yRcNB0D1g3X53fdBKsbqq/yRZ7PJg=; b=hxkoQxW9sxxdh5N+W+qNTn2pFqLUQNrOkHgvBojUrwIqxw7NVjIiUw8GPI5x0fVTAC 0wDBeIt3X3/p4aqypNg0p3kMReWSQu1tjQUw8tZoJ48yzbdfSHMgHfO6MLfIpFaof5Jc Jb3S8OTfJg9iiwvQrFroYPgTJLVQAylJngKICQ+lhKmTuTTocxwY6Kca8+4xx/57Zpx1 MOi9m3Q8xZO9mwqzNa38mxWQJkYnzBIn+O47A0C+zrpoLyM2UGE9ZgNq7/LAhoOC3jC6 4VZyc07/Opkav8MDnX+kG66dhlMMUvfdVKDOHtaQeskxLgSVBuOTaCBhEZ6R0vtcdoqX ghlA== 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 v27si605315eda.233.2017.11.16.01.24.16; Thu, 16 Nov 2017 01:24:16 -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 2C665C21DF7; Thu, 16 Nov 2017 09:23: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 5EEC7C21D93; Thu, 16 Nov 2017 09:22:49 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E9C3DC21D7C; Thu, 16 Nov 2017 09:22:46 +0000 (UTC) Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by lists.denx.de (Postfix) with ESMTP id 966CEC21D6A for ; Thu, 16 Nov 2017 09:22:46 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 85434213E0; Thu, 16 Nov 2017 10:22:45 +0100 (CET) Received: from localhost (unknown [185.94.189.187]) by mail.free-electrons.com (Postfix) with ESMTPSA id 3CFA0203AF; Thu, 16 Nov 2017 10:22:35 +0100 (CET) From: Maxime Ripard To: Tom Rini Date: Thu, 16 Nov 2017 10:22:31 +0100 Message-Id: <20171116092231.27740-11-maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171116092231.27740-1-maxime.ripard@free-electrons.com> References: <20171116092231.27740-1-maxime.ripard@free-electrons.com> Cc: Andre Przywara , agraf@suse.de, u-boot@lists.denx.de, Maxime Ripard , Jagan Teki Subject: [U-Boot] [RFC PATCH 10/10] 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. Signed-off-by: Maxime Ripard Reviewed-by: Lukasz Majewski --- 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