From 77fef22256f63f151ad2953bf9e7e626bd77a732 Mon Sep 17 00:00:00 2001 From: speriaka Date: Mon, 18 Dec 2017 16:49:35 +0530 Subject: [PATCH] ipq807x: uboot: spi : code clean up This patch involves changes which makes sure that spi related functionalities are used only when the config corresponding to it is defined. This change will allow us to disable or enable spi as per our need. Change-Id: I6c3865a6028b9f2a50fe0bface35b1695b17b515 Signed-off-by: speriaka --- board/qca/arm/common/board_init.c | 3 ++- board/qca/arm/common/env.c | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/board/qca/arm/common/board_init.c b/board/qca/arm/common/board_init.c index 9991ca62dd..9f032d21e3 100644 --- a/board/qca/arm/common/board_init.c +++ b/board/qca/arm/common/board_init.c @@ -135,10 +135,11 @@ int board_init(void) printf("BUG: unsupported flash type : %d\n", sfi->flash_type); BUG(); } - if (sfi->flash_type == SMEM_BOOT_SPI_FLASH) { +#ifdef CONFIG_ENV_IS_IN_SPI_FLASH saveenv = sf_saveenv; env_name_spec = sf_env_name_spec; +#endif #ifdef CONFIG_QCA_MMC } else if (sfi->flash_type == SMEM_BOOT_MMC_FLASH) { saveenv = mmc_saveenv; diff --git a/board/qca/arm/common/env.c b/board/qca/arm/common/env.c index 7509ca5b2a..f35122d33f 100644 --- a/board/qca/arm/common/env.c +++ b/board/qca/arm/common/env.c @@ -16,9 +16,12 @@ #include extern void nand_env_relocate_spec(void); -extern void sf_env_relocate_spec(void); extern int nand_env_init(void); + +#ifdef CONFIG_ENV_IS_IN_SPI_FLASH +extern void sf_env_relocate_spec(void); extern int sf_env_init(void); +#endif #ifdef CONFIG_QCA_MMC extern int mmc_env_init(void); @@ -42,7 +45,9 @@ int env_init(void) &sfi.flash_density); if (sfi.flash_type == SMEM_BOOT_SPI_FLASH) { +#ifdef CONFIG_ENV_IS_IN_SPI_FLASH ret = sf_env_init(); +#endif #ifdef CONFIG_QCA_MMC } else if (sfi.flash_type == SMEM_BOOT_MMC_FLASH) { ret = mmc_env_init(); @@ -66,8 +71,10 @@ void env_relocate_spec(void) if (sfi.flash_type == SMEM_BOOT_NO_FLASH) { set_default_env("!flashless boot"); +#ifdef CONFIG_ENV_IS_IN_SPI_FLASH } else if (sfi.flash_type == SMEM_BOOT_SPI_FLASH) { sf_env_relocate_spec(); +#endif #ifdef CONFIG_QCA_MMC } else if (sfi.flash_type == SMEM_BOOT_MMC_FLASH) { mmc_env_relocate_spec();