]> git.sur5r.net Git - u-boot/commitdiff
env: restore old env_get_char() behaviour
authorGoldschmidt Simon <sgoldschmidt@de.pepperl-fuchs.com>
Fri, 9 Feb 2018 20:23:17 +0000 (20:23 +0000)
committerTom Rini <trini@konsulko.com>
Fri, 16 Feb 2018 16:12:42 +0000 (11:12 -0500)
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 <sgoldschmidt@de.pepperl-fuchs.com>
Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
env/eeprom.c
env/env.c
env/nvram.c
include/environment.h

index 55d19d9d99cc19954c746a1bbd393dbca0db44bc..63842d6ff3ee92adc737b15b53924cd327ff9511 100644 (file)
@@ -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),
 };
index edfb575c0e01ee9a7c7ea147823612b22d0cf252..3795dbc24e2bcbb80b066146021f8ea085867a32 100644 (file)
--- a/env/env.c
+++ b/env/env.c
@@ -147,32 +147,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)
index 6f76fe4b8d38a7ca106c84d89df9402f57a4aa04..7cc62b631ecc9cac27b18f10a992b572da403b69 100644 (file)
@@ -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,
index d7037ccd9318b41227078ee707c04eaa35277ef1..7986a242778d1cc3cf37ea29953b4e74e01308f0 100644 (file)
@@ -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
         *