Skip to content
Snippets Groups Projects
Commit 7d714a24 authored by Maxime Ripard's avatar Maxime Ripard Committed by Tom Rini
Browse files

env: Support multiple environments


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.

Reviewed-by: default avatarAndre Przywara <andre.przywara@arm.com>
Reviewed-by: default avatarSimon Glass <sjg@chromium.org>
Signed-off-by: default avatarMaxime Ripard <maxime.ripard@free-electrons.com>
parent 58ae9990
No related branches found
No related tags found
No related merge requests found
...@@ -26,6 +26,44 @@ static struct env_driver *_env_driver_lookup(enum env_location loc) ...@@ -26,6 +26,44 @@ static struct env_driver *_env_driver_lookup(enum env_location loc)
return NULL; return NULL;
} }
static enum env_location env_locations[] = {
#ifdef CONFIG_ENV_IS_IN_EEPROM
ENVL_EEPROM,
#endif
#ifdef CONFIG_ENV_IS_IN_EXT4
ENVL_EXT4,
#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
};
static enum env_location env_load_location = ENVL_UNKNOWN;
/** /**
* env_get_location() - Returns the best env location for a board * env_get_location() - Returns the best env location for a board
* @op: operations performed on the environment * @op: operations performed on the environment
...@@ -45,38 +83,21 @@ static struct env_driver *_env_driver_lookup(enum env_location loc) ...@@ -45,38 +83,21 @@ static struct env_driver *_env_driver_lookup(enum env_location loc)
*/ */
static enum env_location env_get_location(enum env_operation op, int prio) static enum env_location env_get_location(enum env_operation op, int prio)
{ {
/* switch (op) {
* We support a single environment, so any environment asked case ENVOP_GET_CHAR:
* with a priority that is not zero is out of our supported case ENVOP_INIT:
* bounds. case ENVOP_LOAD:
*/ if (prio >= ARRAY_SIZE(env_locations))
if (prio >= 1) return ENVL_UNKNOWN;
return ENVL_UNKNOWN;
env_load_location = env_locations[prio];
if IS_ENABLED(CONFIG_ENV_IS_IN_EEPROM) return env_load_location;
return ENVL_EEPROM;
else if IS_ENABLED(CONFIG_ENV_IS_IN_FAT) case ENVOP_SAVE:
return ENVL_FAT; return env_load_location;
else if IS_ENABLED(CONFIG_ENV_IS_IN_EXT4) }
return ENVL_EXT4;
else if IS_ENABLED(CONFIG_ENV_IS_IN_FLASH) return ENVL_UNKNOWN;
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;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment