mtd: cfi_flash: Use CONFIG_SYS_MONITOR_BASE only when defined
[oweals/u-boot.git] / drivers / mtd / cfi_flash.c
index 6b97e145e99f2a9696c959561defc39b1576fa86..0574fa63a44d2579a87f1ef0186accbb921568db 100644 (file)
 #include <common.h>
 #include <console.h>
 #include <dm.h>
+#include <env.h>
 #include <errno.h>
 #include <fdt_support.h>
 #include <asm/processor.h>
 #include <asm/io.h>
 #include <asm/byteorder.h>
 #include <asm/unaligned.h>
-#include <environment.h>
+#include <env_internal.h>
 #include <mtd/cfi_flash.h>
 #include <watchdog.h>
 
@@ -177,7 +178,8 @@ __maybe_weak u64 flash_read64(void *addr)
 /*-----------------------------------------------------------------------
  */
 #if defined(CONFIG_ENV_IS_IN_FLASH) || defined(CONFIG_ENV_ADDR_REDUND) || \
-       (CONFIG_SYS_MONITOR_BASE >= CONFIG_SYS_FLASH_BASE)
+       (defined(CONFIG_SYS_MONITOR_BASE) && \
+       (CONFIG_SYS_MONITOR_BASE >= CONFIG_SYS_FLASH_BASE))
 static flash_info_t *flash_get_info(ulong base)
 {
        int i;
@@ -2328,7 +2330,8 @@ static void flash_protect_default(void)
 #endif
 
        /* Monitor protection ON by default */
-#if (CONFIG_SYS_MONITOR_BASE >= CONFIG_SYS_FLASH_BASE) && \
+#if defined(CONFIG_SYS_MONITOR_BASE) && \
+       (CONFIG_SYS_MONITOR_BASE >= CONFIG_SYS_FLASH_BASE) && \
        (!defined(CONFIG_MONITOR_IS_IN_RAM))
        flash_protect(FLAG_PROTECT_SET,
                      CONFIG_SYS_MONITOR_BASE,