]> git.sur5r.net Git - u-boot/blobdiff - env/eeprom.c
Migrate CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG to Kconfig
[u-boot] / env / eeprom.c
index ac6b30fa8fc3fc6ae1f7b3a2b664e1eb231bc511..63842d6ff3ee92adc737b15b53924cd327ff9511 100644 (file)
 
 DECLARE_GLOBAL_DATA_PTR;
 
-env_t *env_ptr;
-
-char *env_name_spec = "EEPROM";
-
 static int eeprom_bus_read(unsigned dev_addr, unsigned offset,
                           uchar *buffer, unsigned cnt)
 {
@@ -65,7 +61,10 @@ static int eeprom_bus_write(unsigned dev_addr, unsigned offset,
        return rcode;
 }
 
-uchar env_get_char_spec(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;
@@ -80,7 +79,7 @@ uchar env_get_char_spec(int index)
        return c;
 }
 
-void env_relocate_spec(void)
+static int env_eeprom_load(void)
 {
        char buf_env[CONFIG_ENV_SIZE];
        unsigned int off = CONFIG_ENV_OFFSET;
@@ -126,7 +125,7 @@ void env_relocate_spec(void)
 
        if (!crc_ok[0] && !crc_ok[1]) {
                gd->env_addr    = 0;
-               gd->env_valid   = 0;
+               gd->env_valid = ENV_INVALID;
        } else if (crc_ok[0] && !crc_ok[1]) {
                gd->env_valid = ENV_VALID;
        } else if (!crc_ok[0] && crc_ok[1]) {
@@ -170,9 +169,9 @@ void env_relocate_spec(void)
        }
 
        if (crc == new) {
-               gd->env_valid   = ENV_VALID;
+               gd->env_valid = ENV_VALID;
        } else {
-               gd->env_valid   = 0;
+               gd->env_valid = ENV_INVALID;
        }
 #endif /* CONFIG_ENV_OFFSET_REDUND */
 
@@ -185,10 +184,10 @@ void env_relocate_spec(void)
        eeprom_bus_read(CONFIG_SYS_DEF_EEPROM_ADDR,
                off, (uchar *)buf_env, CONFIG_ENV_SIZE);
 
-       env_import(buf_env, 1);
+       return env_import(buf_env, 1);
 }
 
-int saveenv(void)
+static int env_eeprom_save(void)
 {
        env_t   env_new;
        int     rc;
@@ -198,8 +197,6 @@ int saveenv(void)
        char flag_obsolete      = OBSOLETE_FLAG;
 #endif
 
-       BUG_ON(env_ptr != NULL);
-
        rc = env_export(&env_new);
        if (rc)
                return rc;
@@ -231,15 +228,9 @@ int saveenv(void)
        return rc;
 }
 
-/*
- * Initialize Environment use
- *
- * We are still running from ROM, so data use is limited.
- * Use a (moderately small) buffer on the stack
- */
-int env_init(void)
-{
-       gd->env_addr = (ulong)&default_environment[0];
-       gd->env_valid = ENV_VALID;
-       return 0;
-}
+U_BOOT_ENV_LOCATION(eeprom) = {
+       .location       = ENVL_EEPROM,
+       ENV_NAME("EEPROM")
+       .load           = env_eeprom_load,
+       .save           = env_save_ptr(env_eeprom_save),
+};