arch: Add explicit linker script for u-boot-elf
[oweals/u-boot.git] / env / fat.c
index 158a9a34357bb8eb791ac3372c977d9a0d2b698e..1836556f361d012e0bcd5ba54323475fe181e8a3 100644 (file)
--- a/env/fat.c
+++ b/env/fat.c
@@ -1,16 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * (c) Copyright 2011 by Tigris Elektronik GmbH
  *
  * Author:
  *  Maximilian Schwerin <mvs@tigris.de>
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
 
 #include <command.h>
-#include <environment.h>
+#include <env.h>
+#include <env_internal.h>
 #include <linux/stddef.h>
 #include <malloc.h>
 #include <memalign.h>
 # endif
 #endif
 
-DECLARE_GLOBAL_DATA_PTR;
-
 #ifdef CMD_SAVEENV
 static int env_fat_save(void)
 {
-       env_t   env_new;
+       env_t __aligned(ARCH_DMA_MINALIGN) env_new;
        struct blk_desc *dev_desc = NULL;
        disk_partition_t info;
        int dev, part;
@@ -89,6 +87,11 @@ static int env_fat_load(void)
        int dev, part;
        int err;
 
+#ifdef CONFIG_MMC
+       if (!strcmp(CONFIG_ENV_FAT_INTERFACE, "mmc"))
+               mmc_initialize(NULL);
+#endif
+
        part = blk_get_device_part_str(CONFIG_ENV_FAT_INTERFACE,
                                        CONFIG_ENV_FAT_DEVICE_AND_PART,
                                        &dev_desc, &info, 1);
@@ -117,11 +120,10 @@ static int env_fat_load(void)
                goto err_env_relocate;
        }
 
-       env_import(buf, 1);
-       return 0;
+       return env_import(buf, 1);
 
 err_env_relocate:
-       set_default_env(NULL);
+       env_set_default(NULL, 0);
 
        return -EIO;
 }