static int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc,
char * const argv[])
{
- printf("Saving Environment to %s...\n", env_name_spec);
+ struct env_driver *env = env_driver_lookup_default();
+
+ printf("Saving Environment to %s...\n", env->name);
return saveenv() ? 1 : 0;
}
env_t *env_ptr;
-char *env_name_spec = "dataflash";
-
static unsigned char env_dataflash_get_char(int index)
{
uchar c;
U_BOOT_ENV_LOCATION(dataflash) = {
.location = ENVL_DATAFLASH,
+ ENV_NAME("dataflash")
.get_char = env_dataflash_get_char,
.load = env_dataflash_load,
.save = env_save_ptr(env_dataflash_save),
env_t *env_ptr;
-char *env_name_spec = "EEPROM";
-
static int eeprom_bus_read(unsigned dev_addr, unsigned offset,
uchar *buffer, unsigned cnt)
{
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),
return ENVL_UNKNOWN;
}
-static struct env_driver *env_driver_lookup_default(void)
+struct env_driver *env_driver_lookup_default(void)
{
enum env_location loc = env_get_default_location();
struct env_driver *drv;
#include <ext4fs.h>
#include <mmc.h>
-char *env_name_spec = "EXT4";
-
env_t *env_ptr;
DECLARE_GLOBAL_DATA_PTR;
U_BOOT_ENV_LOCATION(ext4) = {
.location = ENVL_EXT4,
+ ENV_NAME("EXT4")
.load = env_ext4_load,
.save = env_save_ptr(env_ext4_save),
};
# endif
#endif
-char *env_name_spec = "FAT";
-
env_t *env_ptr;
DECLARE_GLOBAL_DATA_PTR;
U_BOOT_ENV_LOCATION(fat) = {
.location = ENVL_FAT,
+ ENV_NAME("FAT")
#ifdef LOADENV
.load = env_fat_load,
#endif
#define INITENV
#endif
-char *env_name_spec = "Flash";
-
#ifdef ENV_IS_EMBEDDED
env_t *env_ptr = &environment;
U_BOOT_ENV_LOCATION(flash) = {
.location = ENVL_FLASH,
+ ENV_NAME("Flash")
#ifdef LOADENV
.load = env_flash_load,
#endif
#error CONFIG_ENV_SIZE_REDUND should be the same as CONFIG_ENV_SIZE
#endif
-char *env_name_spec = "MMC";
-
#ifdef ENV_IS_EMBEDDED
env_t *env_ptr = &environment;
#else /* ! ENV_IS_EMBEDDED */
U_BOOT_ENV_LOCATION(mmc) = {
.location = ENVL_MMC,
+ ENV_NAME("MMC")
.load = env_mmc_load,
#ifndef CONFIG_SPL_BUILD
.save = env_save_ptr(env_mmc_save),
#define CONFIG_ENV_RANGE CONFIG_ENV_SIZE
#endif
-char *env_name_spec = "NAND";
-
#if defined(ENV_IS_EMBEDDED)
env_t *env_ptr = &environment;
#elif defined(CONFIG_NAND_ENV_DST)
U_BOOT_ENV_LOCATION(nand) = {
.location = ENVL_NAND,
+ ENV_NAME("NAND")
.load = env_nand_load,
#if defined(CMD_SAVEENV)
.save = env_save_ptr(env_nand_save),
U_BOOT_ENV_LOCATION(nowhere) = {
.location = ENVL_NOWHERE,
+ ENV_NAME("nowhere")
};
env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR;
#endif
-char *env_name_spec = "NVRAM";
-
#ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE
static uchar env_nvram_get_char(int index)
{
U_BOOT_ENV_LOCATION(nvram) = {
.location = ENVL_NVRAM,
+ ENV_NAME("NVRAM")
#ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE
.get_char = env_nvram_get_char,
#endif
#include <linux/mtd/mtd.h>
#include <linux/mtd/onenand.h>
-char *env_name_spec = "OneNAND";
-
#define ONENAND_MAX_ENV_SIZE CONFIG_ENV_SIZE
#define ONENAND_ENV_SIZE(mtd) (ONENAND_MAX_ENV_SIZE - ENV_HEADER_SIZE)
U_BOOT_ENV_LOCATION(onenand) = {
.location = ENVL_ONENAND,
+ ENV_NAME("OneNAND")
.load = env_onenand_load,
.save = env_save_ptr(env_onenand_save),
};
#include <environment.h>
#include <linux/stddef.h>
-char *env_name_spec = "Remote";
-
#ifdef ENV_IS_EMBEDDED
env_t *env_ptr = &environment;
#else /* ! ENV_IS_EMBEDDED */
U_BOOT_ENV_LOCATION(remote) = {
.location = ENVL_REMOTE,
+ ENV_NAME("Remote")
.load = env_remote_load,
.save = env_save_ptr(env_remote_save),
.init = env_remote_init,
#error CONFIG_ENV_OFFSET or CONFIG_ENV_SIZE not defined
#endif
-char *env_name_spec = "SATA";
-
DECLARE_GLOBAL_DATA_PTR;
__weak int sata_get_env_dev(void)
U_BOOT_ENV_LOCATION(sata) = {
.location = ENVL_ESATA,
+ ENV_NAME("SATA")
.load = env_sata_load,
.save = env_save_ptr(env_sata_save),
};
DECLARE_GLOBAL_DATA_PTR;
-char *env_name_spec = "SPI Flash";
-
static struct spi_flash *env_flash;
static int setup_flash_device(void)
U_BOOT_ENV_LOCATION(sf) = {
.location = ENVL_SPI_FLASH,
+ ENV_NAME("SPI Flash")
.load = env_sf_load,
#ifdef CMD_SAVEENV
.save = env_save_ptr(env_sf_save),
#include <ubi_uboot.h>
#undef crc32
-char *env_name_spec = "UBI";
-
env_t *env_ptr;
DECLARE_GLOBAL_DATA_PTR;
# define ENV_HEADER_SIZE (sizeof(uint32_t))
#endif
-#if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
-extern char *env_name_spec;
-#endif
-
#ifdef CONFIG_ENV_AES
/* Make sure the payload is multiple of AES block size */
#define ENV_SIZE ((CONFIG_ENV_SIZE - ENV_HEADER_SIZE) & ~(16 - 1))
};
struct env_driver {
+ const char *name;
enum env_location location;
/**
#define U_BOOT_ENV_LOCATION(__name) \
ll_entry_declare(struct env_driver, __name, env_driver)
+/* Declare the name of a location */
+#ifdef CONFIG_CMD_SAVEENV
+#define ENV_NAME(_name) .name = _name,
+#else
+#define ENV_NAME(_name)
+#endif
+
#ifdef CONFIG_CMD_SAVEENV
#define env_save_ptr(x) x
#else
int env_import_redund(const char *buf1, const char *buf2);
#endif
+/**
+ * env_driver_lookup_default() - Look up the default environment driver
+ *
+ * @return pointer to driver, or NULL if none (which should not happen)
+ */
+struct env_driver *env_driver_lookup_default(void);
+
#endif /* DO_DEPS_ONLY */
#endif /* _ENVIRONMENT_H_ */