lmb: allow lmb module to be used in SPL
With the introduction of separate config symbols for the SPL phase of
U-Boot, the condition checks need to be tweaked so that platforms that
enable the LMB module in SPL are also able to call the LMB API's. Use
the appropriate condition checks to achieve this.
Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
diff --git a/net/tftp.c b/net/tftp.c
index c0a6210..99b2ab9 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -82,9 +82,7 @@
static ulong tftp_block_wrap_offset;
static int tftp_state;
static ulong tftp_load_addr;
-#ifdef CONFIG_LMB
static ulong tftp_load_size;
-#endif
#ifdef CONFIG_TFTP_TSIZE
/* The file size reported by the server */
static int tftp_tsize;
@@ -160,19 +158,20 @@
ulong store_addr = tftp_load_addr + offset;
void *ptr;
-#ifdef CONFIG_LMB
- ulong end_addr = tftp_load_addr + tftp_load_size;
+ if (CONFIG_IS_ENABLED(LMB)) {
+ ulong end_addr = tftp_load_addr + tftp_load_size;
- if (!end_addr)
- end_addr = ULONG_MAX;
+ if (!end_addr)
+ end_addr = ULONG_MAX;
- if (store_addr < tftp_load_addr ||
- store_addr + len > end_addr) {
- puts("\nTFTP error: ");
- puts("trying to overwrite reserved memory...\n");
- return -1;
+ if (store_addr < tftp_load_addr ||
+ store_addr + len > end_addr) {
+ puts("\nTFTP error: ");
+ puts("trying to overwrite reserved memory...\n");
+ return -1;
+ }
}
-#endif
+
ptr = map_sysmem(store_addr, len);
memcpy(ptr, src, len);
unmap_sysmem(ptr);
@@ -716,17 +715,18 @@
/* Initialize tftp_load_addr and tftp_load_size from image_load_addr and lmb */
static int tftp_init_load_addr(void)
{
-#ifdef CONFIG_LMB
- phys_size_t max_size;
+ if (CONFIG_IS_ENABLED(LMB)) {
+ phys_size_t max_size;
- lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
+ lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);
- max_size = lmb_get_free_size(image_load_addr);
- if (!max_size)
- return -1;
+ max_size = lmb_get_free_size(image_load_addr);
+ if (!max_size)
+ return -1;
- tftp_load_size = max_size;
-#endif
+ tftp_load_size = max_size;
+ }
+
tftp_load_addr = image_load_addr;
return 0;
}