#include <dm/device-internal.h>
#include <u-boot/crc.h>
-#ifndef CONFIG_SPL_BUILD
-#define INITENV
-#endif
-
#define OFFSET_INVALID (~(u32)0)
#ifdef CONFIG_ENV_OFFSET_REDUND
return ret;
}
-#if CONFIG_ENV_ADDR != 0x0
__weak void *env_sf_get_env_addr(void)
{
+#ifndef CONFIG_SPL_BUILD
return (void *)CONFIG_ENV_ADDR;
-}
+#else
+ return NULL;
#endif
+}
-#if defined(INITENV) && (CONFIG_ENV_ADDR != 0x0)
/*
* check if Environment on CONFIG_ENV_ADDR is valid.
*/
{
env_t *env_ptr = (env_t *)env_sf_get_env_addr();
+ if (!env_ptr)
+ return -ENOENT;
+
if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) {
gd->env_addr = (ulong)&(env_ptr->data);
gd->env_valid = ENV_VALID;
return 0;
}
-#endif
#if defined(CONFIG_ENV_SPI_EARLY)
/*
static int env_sf_init(void)
{
-#if defined(INITENV) && (CONFIG_ENV_ADDR != 0x0)
- return env_sf_init_addr();
-#elif defined(CONFIG_ENV_SPI_EARLY)
+ int ret = env_sf_init_addr();
+ if (ret != -ENOENT)
+ return ret;
+#ifdef CONFIG_ENV_SPI_EARLY
return env_sf_init_early();
#endif
/*