From patchwork Fri Feb 9 20:23:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Goldschmidt X-Patchwork-Id: 871566 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3zdRN26yWDz9s7M for ; Sat, 10 Feb 2018 07:23:29 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 290D7C21DA1; Fri, 9 Feb 2018 20:23:25 +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 4E888C21D75; Fri, 9 Feb 2018 20:23:22 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 42AF1C21D75; Fri, 9 Feb 2018 20:23:20 +0000 (UTC) Received: from mailout.pepperl-fuchs.com (mailout.pepperl-fuchs.com [212.21.166.229]) by lists.denx.de (Postfix) with ESMTPS id E61E9C21D74 for ; Fri, 9 Feb 2018 20:23:19 +0000 (UTC) Received: from PFDE-CAS2.EU.P-F.BIZ (pfde-cas2.eu.p-f.biz [172.24.5.134]) by mailout.pepperl-fuchs.com (Postfix) with ESMTP id AF7E581AEB; Fri, 9 Feb 2018 21:23:19 +0100 (CET) Received: from PFDE-MX10.EU.P-F.BIZ ([fe80::d5f0:bcf5:78eb:66cd]) by PFDE-CAS2.EU.P-F.BIZ ([fe80::8109:cac5:bde5:6fd3%18]) with mapi id 14.03.0301.000; Fri, 9 Feb 2018 21:23:18 +0100 From: Goldschmidt Simon To: "u-boot@lists.denx.de" Thread-Topic: [PATCH] env: restore old env_get_char() behaviour Thread-Index: AdOh49GyLovjKCjpTia10heLVGlUgw== Date: Fri, 9 Feb 2018 20:23:17 +0000 Message-ID: Accept-Language: de-DE, en-US Content-Language: de-DE X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.24.5.147] x-exclaimer-md-config: 1e262833-c6b8-4d86-a546-40bddc43f2e2 MIME-Version: 1.0 Cc: Andre Przywara , Fiach Antaw , "Maxime, Ripard" , Andy Yan Subject: [U-Boot] [PATCH] env: restore old env_get_char() behaviour X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" With multiple environments, the 'get_char' callback for env drivers does not really make sense any more because it is only supported by two drivers (eeprom and nvram). To restore single character loading for these drivers, override 'env_get_char_spec'. Signed-off-by: Simon Goldschmidt Acked-by: Maxime Ripard --- env/eeprom.c | 6 ++++-- env/env.c | 29 +++++++---------------------- env/nvram.c | 8 ++++---- include/environment.h | 11 ----------- 4 files changed, 15 insertions(+), 39 deletions(-) diff --git a/env/eeprom.c b/env/eeprom.c index 55d19d9d99..63842d6ff3 100644 --- a/env/eeprom.c +++ b/env/eeprom.c @@ -61,7 +61,10 @@ static int eeprom_bus_write(unsigned dev_addr, unsigned offset, return rcode; } -static int env_eeprom_get_char(int index) +/** Call this function from overridden env_get_char_spec() if you need + * this functionality. + */ +int env_eeprom_get_char(int index) { uchar c; unsigned int off = CONFIG_ENV_OFFSET; @@ -228,7 +231,6 @@ static int env_eeprom_save(void) U_BOOT_ENV_LOCATION(eeprom) = { .location = ENVL_EEPROM, ENV_NAME("EEPROM") - .get_char = env_eeprom_get_char, .load = env_eeprom_load, .save = env_save_ptr(env_eeprom_save), }; diff --git a/env/env.c b/env/env.c index 9a89832c1a..ab12606207 100644 --- a/env/env.c +++ b/env/env.c @@ -149,32 +149,17 @@ static struct env_driver *env_driver_lookup(enum env_operation op, int prio) return drv; } -int env_get_char(int index) +__weak int env_get_char_spec(int index) { - struct env_driver *drv; - int prio; + return *(uchar *)(gd->env_addr + index); +} +int env_get_char(int index) +{ if (gd->env_valid == ENV_INVALID) return default_environment[index]; - - for (prio = 0; (drv = env_driver_lookup(ENVOP_GET_CHAR, prio)); prio++) { - int ret; - - if (!drv->get_char) - continue; - - if (!env_has_inited(drv->location)) - 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 -ENODEV; + else + return env_get_char_spec(index); } int env_load(void) diff --git a/env/nvram.c b/env/nvram.c index 6f76fe4b8d..7cc62b631e 100644 --- a/env/nvram.c +++ b/env/nvram.c @@ -41,7 +41,10 @@ env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR; #endif #ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE -static int env_nvram_get_char(int index) +/** Call this function from overridden env_get_char_spec() if you need + * this functionality. + */ +int env_nvram_get_char(int index) { uchar c; @@ -113,9 +116,6 @@ static int env_nvram_init(void) U_BOOT_ENV_LOCATION(nvram) = { .location = ENVL_NVRAM, ENV_NAME("NVRAM") -#ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE - .get_char = env_nvram_get_char, -#endif .load = env_nvram_load, .save = env_save_ptr(env_nvram_save), .init = env_nvram_init, diff --git a/include/environment.h b/include/environment.h index 6044b9e1b4..8696573d0d 100644 --- a/include/environment.h +++ b/include/environment.h @@ -217,17 +217,6 @@ struct env_driver { const char *name; enum env_location location; - /** - * get_char() - Read a character from the environment - * - * This method is optional. If not provided, a default implementation - * will read from gd->env_addr. - * - * @index: Index of character to read (0=first) - * @return character read, or -ve on error - */ - int (*get_char)(int index); - /** * load() - Load the environment from storage *