X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=env%2Feeprom.c;h=ac2689cc148c43c07c945db22494d0d49a5fe301;hb=e0ed8332fa2fe684b4c8ba1caab991663730cbf0;hp=3cc412620acdc998de87cc50c450bddbe5181d01;hpb=7938822a6b75b69fff9793b6b1769dddf1249525;p=oweals%2Fu-boot.git diff --git a/env/eeprom.c b/env/eeprom.c index 3cc412620a..ac2689cc14 100644 --- a/env/eeprom.c +++ b/env/eeprom.c @@ -1,11 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * (C) Copyright 2000-2010 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * * (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH * Andreas Heppel - * - * SPDX-License-Identifier: GPL-2.0+ */ #include @@ -21,10 +20,6 @@ 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 +60,10 @@ static int eeprom_bus_write(unsigned dev_addr, unsigned offset, return rcode; } -static uchar 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; @@ -80,7 +78,7 @@ static uchar env_eeprom_get_char(int index) return c; } -static void env_eeprom_load(void) +static int env_eeprom_load(void) { char buf_env[CONFIG_ENV_SIZE]; unsigned int off = CONFIG_ENV_OFFSET; @@ -126,7 +124,7 @@ static void env_eeprom_load(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 +168,9 @@ static void env_eeprom_load(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,7 +183,7 @@ static void env_eeprom_load(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); } static int env_eeprom_save(void) @@ -198,8 +196,6 @@ static int env_eeprom_save(void) char flag_obsolete = OBSOLETE_FLAG; #endif - BUG_ON(env_ptr != NULL); - rc = env_export(&env_new); if (rc) return rc; @@ -233,7 +229,7 @@ static int env_eeprom_save(void) U_BOOT_ENV_LOCATION(eeprom) = { .location = ENVL_EEPROM, - .get_char = env_eeprom_get_char, + ENV_NAME("EEPROM") .load = env_eeprom_load, .save = env_save_ptr(env_eeprom_save), };