diff options
author | Tom Rini <trini@konsulko.com> | 2020-07-27 09:25:53 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-07-27 09:25:53 -0400 |
commit | 3773028fced4795d52f02b387496395ec387f3bb (patch) | |
tree | ab11a71616bc9d5534d4b633520819c1b9be8b9c /env/fat.c | |
parent | ada61f1ee2a4eaa1b29d699b5ba940483171df8a (diff) | |
parent | 5d4f7b4e2a1a2df459172ec95cbcdd6373dd707a (diff) |
Merge branch '2020-07-27-misc-env-improvements'
- Assorted environment fixes.
- Enhance environment in MMC and controlled via OF_CONTROL
- Allow for environment in FAT to use the same device we boot from
rather than be hard-coded.
Diffstat (limited to 'env/fat.c')
-rw-r--r-- | env/fat.c | 32 |
1 files changed, 30 insertions, 2 deletions
@@ -29,6 +29,34 @@ # define LOADENV #endif +__weak int mmc_get_env_dev(void) +{ +#ifdef CONFIG_SYS_MMC_ENV_DEV + return CONFIG_SYS_MMC_ENV_DEV; +#else + return 0; +#endif +} + +static char *env_fat_device_and_part(void) +{ +#ifdef CONFIG_MMC + static char *part_str; + + if (!part_str) { + part_str = CONFIG_ENV_FAT_DEVICE_AND_PART; + if (!strcmp(CONFIG_ENV_FAT_INTERFACE, "mmc") && part_str[0] == ':') { + part_str = "0" CONFIG_ENV_FAT_DEVICE_AND_PART; + part_str[0] += mmc_get_env_dev(); + } + } + + return part_str; +#else + return CONFIG_ENV_FAT_DEVICE_AND_PART; +#endif +} + static int env_fat_save(void) { env_t __aligned(ARCH_DMA_MINALIGN) env_new; @@ -43,7 +71,7 @@ static int env_fat_save(void) return err; part = blk_get_device_part_str(CONFIG_ENV_FAT_INTERFACE, - CONFIG_ENV_FAT_DEVICE_AND_PART, + env_fat_device_and_part(), &dev_desc, &info, 1); if (part < 0) return 1; @@ -89,7 +117,7 @@ static int env_fat_load(void) #endif part = blk_get_device_part_str(CONFIG_ENV_FAT_INTERFACE, - CONFIG_ENV_FAT_DEVICE_AND_PART, + env_fat_device_and_part(), &dev_desc, &info, 1); if (part < 0) goto err_env_relocate; |