[U-Boot] [PATCH v3 15/15] of: clean up OF_CONTROL ifdef conditionals

Masahiro Yamada
2015-08-11T22:31:55Z

We have flipped CONFIG_SPL_DISABLE_OF_CONTROL. We have cleansing
devices, $(SPL_) and CONFIG_IS_ENABLED(), so we are ready to clear
away the ugly logic in include/fdtdec.h:

#ifdef CONFIG_OF_CONTROL
# if defined(CONFIG_SPL_BUILD) && !defined(SPL_OF_CONTROL)
# define OF_CONTROL 0
# else
# define OF_CONTROL 1
# endif
#else
# define OF_CONTROL 0
#endif

Now CONFIG_IS_ENABLED(OF_CONTROL) is the substitute. It refers to
CONFIG_OF_CONTROL for U-boot proper and CONFIG_SPL_OF_CONTROL for
SPL.

Also, we no longer have to cancel CONFIG_OF_CONTROL in
include/config_uncmd_spl.h and scripts/Makefile.spl.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

Changes in v3:
- Rebase on commit bd48c0617b5c721

Changes in v2: None

arch/arm/cpu/armv7/am33xx/board.c | 2 +-
arch/arm/cpu/armv7/exynos/pinmux.c | 2 +-
arch/arm/include/asm/arch-exynos/dwmmc.h | 2 --
arch/arm/include/asm/arch-exynos/mipi_dsim.h | 2 --
arch/arm/include/asm/arch-exynos/mmc.h | 2 --
arch/arm/mach-tegra/clock.c | 4 ++--
arch/arm/mach-tegra/tegra114/clock.c | 4 ++--
arch/arm/mach-tegra/tegra124/clock.c | 4 ++--
arch/arm/mach-tegra/tegra20/clock.c | 4 ++--
arch/arm/mach-tegra/tegra30/clock.c | 4 ++--
board/xilinx/microblaze-generic/microblaze-generic.c | 2 +-
board/xilinx/zynq/board.c | 2 +-
common/cli.c | 4 ++--
common/spl/spl.c | 3 +--
drivers/core/Makefile | 2 +-
drivers/core/device.c | 4 ++--
drivers/core/lists.c | 2 +-
drivers/core/root.c | 6 +++---
drivers/gpio/mxc_gpio.c | 2 +-
drivers/gpio/vybrid_gpio.c | 2 +-
drivers/i2c/s3c24x0_i2c.c | 4 ++--
drivers/input/Makefile | 2 +-
drivers/input/tegra-kbc.c | 2 +-
drivers/mmc/exynos_dw_mmc.c | 2 +-
drivers/mmc/s5p_sdhci.c | 2 +-
drivers/mmc/tegra_mmc.c | 2 +-
drivers/mmc/zynq_sdhci.c | 2 +-
drivers/mtd/spi/sf_probe.c | 6 +++---
drivers/net/xilinx_emaclite.c | 2 +-
drivers/net/zynq_gem.c | 2 +-
drivers/power/exynos-tmu.c | 2 +-
drivers/power/pmic/pmic_max77686.c | 4 ++--
drivers/serial/ns16550.c | 2 +-
drivers/serial/serial-uclass.c | 4 ++--
drivers/serial/serial_omap.c | 2 +-
drivers/serial/serial_pl01x.c | 2 +-
drivers/serial/serial_tegra.c | 4 ++--
drivers/serial/serial_uniphier.c | 2 +-
drivers/serial/serial_zynq.c | 2 +-
drivers/sound/max98095.c | 2 +-
drivers/sound/wm8994.c | 2 +-
drivers/tpm/tpm_tis_i2c.c | 2 +-
drivers/video/exynos_dp_lowlevel.c | 2 +-
drivers/video/exynos_fb.c | 8 ++++----
drivers/video/exynos_fimd.c | 4 ++--
drivers/video/exynos_mipi_dsi.c | 4 ++--
drivers/video/tegra.c | 2 +-
include/cli.h | 2 +-
include/config_uncmd_spl.h | 3 ---
include/configs/microblaze-generic.h | 3 ++-
include/configs/socfpga_common.h | 2 +-
include/dm/device.h | 4 ++--
include/fdtdec.h | 10 ----------
lib/Makefile | 11 ++++-------
lib/fdtdec.c | 2 +-
scripts/Makefile.uncmd_spl | 3 ---
56 files changed, 75 insertions(+), 100 deletions(-)

diff --git a/arch/arm/cpu/armv7/am33xx/board.c b/arch/arm/cpu/armv7/am33xx/board.c
index 377c611..3224f93 100644
--- a/arch/arm/cpu/armv7/am33xx/board.c
+++ b/arch/arm/cpu/armv7/am33xx/board.c
@@ -61,7 +61,7 @@ U_BOOT_DEVICES(am33xx_gpios) = {
#endif
};

-# ifndef CONFIG_OF_CONTROL
+# if !CONFIG_IS_ENABLED(OF_CONTROL)
/*
* TODO(sjg at chromium.org): When we can move SPL serial to DM, we can remove
* the CONFIGs. At the same time, we should move this to the board files.
diff --git a/arch/arm/cpu/armv7/exynos/pinmux.c b/arch/arm/cpu/armv7/exynos/pinmux.c
index e97cb37..179b294 100644
--- a/arch/arm/cpu/armv7/exynos/pinmux.c
+++ b/arch/arm/cpu/armv7/exynos/pinmux.c
@@ -874,7 +874,7 @@ int exynos_pinmux_config(int peripheral, int flags)
return -1;
}

-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
static int exynos4_pinmux_decode_periph_id(const void *blob, int node)
{
int err;
diff --git a/arch/arm/include/asm/arch-exynos/dwmmc.h b/arch/arm/include/asm/arch-exynos/dwmmc.h
index a7ca12c..bd997ad 100644
--- a/arch/arm/include/asm/arch-exynos/dwmmc.h
+++ b/arch/arm/include/asm/arch-exynos/dwmmc.h
@@ -27,7 +27,5 @@
#define DWMCI_DIVRATIO_BIT 24
#define DWMCI_DIVRATIO_MASK 0x7

-#ifdef CONFIG_OF_CONTROL
int exynos_dwmmc_init(const void *blob);
-#endif
int exynos_dwmci_add_port(int index, u32 regbase, int bus_width, u32 clksel);
diff --git a/arch/arm/include/asm/arch-exynos/mipi_dsim.h b/arch/arm/include/asm/arch-exynos/mipi_dsim.h
index 50e5c25..c9e8e06 100644
--- a/arch/arm/include/asm/arch-exynos/mipi_dsim.h
+++ b/arch/arm/include/asm/arch-exynos/mipi_dsim.h
@@ -374,7 +374,5 @@ void exynos_init_dsim_platform_data(vidinfo_t *vid);
/* panel driver init based on mipi dsi interface */
void s6e8ax0_init(void);

-#ifdef CONFIG_OF_CONTROL
extern int mipi_power(void);
-#endif
#endif /* _DSIM_H */
diff --git a/arch/arm/include/asm/arch-exynos/mmc.h b/arch/arm/include/asm/arch-exynos/mmc.h
index 0fb6461..48b8c4d 100644
--- a/arch/arm/include/asm/arch-exynos/mmc.h
+++ b/arch/arm/include/asm/arch-exynos/mmc.h
@@ -65,8 +65,6 @@ static inline int s5p_mmc_init(int index, int bus_width)
return s5p_sdhci_init(base, index, bus_width);
}

-#ifdef CONFIG_OF_CONTROL
int exynos_mmc_init(const void *blob);
-#endif

#endif
diff --git a/arch/arm/mach-tegra/clock.c b/arch/arm/mach-tegra/clock.c
index 3b2b4ff..83fa837 100644
--- a/arch/arm/mach-tegra/clock.c
+++ b/arch/arm/mach-tegra/clock.c
@@ -564,7 +564,7 @@ void clock_ll_start_uart(enum periph_id periph_id)
reset_set_enable(periph_id, 0);
}

-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
int clock_decode_periph_id(const void *blob, int node)
{
enum periph_id id;
@@ -579,7 +579,7 @@ int clock_decode_periph_id(const void *blob, int node)
assert(clock_periph_id_isvalid(id));
return id;
}
-#endif /* CONFIG_OF_CONTROL */
+#endif /* CONFIG_IS_ENABLED(OF_CONTROL) */

int clock_verify(void)
{
diff --git a/arch/arm/mach-tegra/tegra114/clock.c b/arch/arm/mach-tegra/tegra114/clock.c
index f1831d3..5e805a7 100644
--- a/arch/arm/mach-tegra/tegra114/clock.c
+++ b/arch/arm/mach-tegra/tegra114/clock.c
@@ -582,7 +582,7 @@ void reset_set_enable(enum periph_id periph_id, int enable)
writel(reg, reset);
}

-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
/*
* Convert a device tree clock ID to our peripheral ID. They are mostly
* the same but we are very cautious so we check that a valid clock ID is
@@ -618,7 +618,7 @@ enum periph_id clk_id_to_periph_id(int clk_id)
return clk_id;
}
}
-#endif /* CONFIG_OF_CONTROL */
+#endif /* CONFIG_IS_ENABLED(OF_CONTROL) */

void clock_early_init(void)
{
diff --git a/arch/arm/mach-tegra/tegra124/clock.c b/arch/arm/mach-tegra/tegra124/clock.c
index 9126218..cca11d4 100644
--- a/arch/arm/mach-tegra/tegra124/clock.c
+++ b/arch/arm/mach-tegra/tegra124/clock.c
@@ -730,7 +730,7 @@ void reset_set_enable(enum periph_id periph_id, int enable)
writel(reg, reset);
}

-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
/*
* Convert a device tree clock ID to our peripheral ID. They are mostly
* the same but we are very cautious so we check that a valid clock ID is
@@ -796,7 +796,7 @@ enum periph_id clk_id_to_periph_id(int clk_id)
return clk_id;
}
}
-#endif /* CONFIG_OF_CONTROL */
+#endif /* CONFIG_IS_ENABLED(OF_CONTROL) */

void clock_early_init(void)
{
diff --git a/arch/arm/mach-tegra/tegra20/clock.c b/arch/arm/mach-tegra/tegra20/clock.c
index dea459b..cd9fb9a 100644
--- a/arch/arm/mach-tegra/tegra20/clock.c
+++ b/arch/arm/mach-tegra/tegra20/clock.c
@@ -507,7 +507,7 @@ void reset_set_enable(enum periph_id periph_id, int enable)
writel(reg, reset);
}

-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
/*
* Convert a device tree clock ID to our peripheral ID. They are mostly
* the same but we are very cautious so we check that a valid clock ID is
@@ -542,7 +542,7 @@ enum periph_id clk_id_to_periph_id(int clk_id)
return clk_id;
}
}
-#endif /* CONFIG_OF_CONTROL */
+#endif /* CONFIG_IS_ENABLED(OF_CONTROL) */

void clock_early_init(void)
{
diff --git a/arch/arm/mach-tegra/tegra30/clock.c b/arch/arm/mach-tegra/tegra30/clock.c
index 3ce508b..1f104f2 100644
--- a/arch/arm/mach-tegra/tegra30/clock.c
+++ b/arch/arm/mach-tegra/tegra30/clock.c
@@ -562,7 +562,7 @@ void reset_set_enable(enum periph_id periph_id, int enable)
writel(reg, reset);
}

-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
/*
* Convert a device tree clock ID to our peripheral ID. They are mostly
* the same but we are very cautious so we check that a valid clock ID is
@@ -600,7 +600,7 @@ enum periph_id clk_id_to_periph_id(int clk_id)
return clk_id;
}
}
-#endif /* CONFIG_OF_CONTROL */
+#endif /* CONFIG_IS_ENABLED(OF_CONTROL) */

void clock_early_init(void)
{
diff --git a/board/xilinx/microblaze-generic/microblaze-generic.c b/board/xilinx/microblaze-generic/microblaze-generic.c
index 375cd0b..0c8bd7d 100644
--- a/board/xilinx/microblaze-generic/microblaze-generic.c
+++ b/board/xilinx/microblaze-generic/microblaze-generic.c
@@ -24,7 +24,7 @@ DECLARE_GLOBAL_DATA_PTR;
static int reset_pin = -1;
#endif

-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
ulong ram_base;

void dram_init_banksize(void)
diff --git a/board/xilinx/zynq/board.c b/board/xilinx/zynq/board.c
index 738c31c..237f2c2 100644
--- a/board/xilinx/zynq/board.c
+++ b/board/xilinx/zynq/board.c
@@ -154,7 +154,7 @@ int board_mmc_init(bd_t *bd)

int dram_init(void)
{
-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
int node;
fdt_addr_t addr;
fdt_size_t size;
diff --git a/common/cli.c b/common/cli.c
index 075ae9d..b6ae80a 100644
--- a/common/cli.c
+++ b/common/cli.c
@@ -135,7 +135,7 @@ int do_run(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
}
#endif

-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
bool cli_process_fdt(const char **cmdp)
{
/* Allow the fdt to override the boot command */
@@ -196,7 +196,7 @@ err:
*/
hang();
}
-#endif /* CONFIG_OF_CONTROL */
+#endif /* CONFIG_IS_ENABLED(OF_CONTROL) */

void cli_loop(void)
{
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 45cf925..a5892d7 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -157,8 +157,7 @@ int spl_init(void)
gd->malloc_limit = CONFIG_SYS_MALLOC_F_LEN;
gd->malloc_ptr = 0;
#endif
- if (IS_ENABLED(CONFIG_OF_CONTROL) &&
- IS_ENABLED(CONFIG_SPL_OF_CONTROL)) {
+ if (CONFIG_IS_ENABLED(OF_CONTROL)) {
ret = fdtdec_setup();
if (ret) {
debug("fdtdec_setup() returned error %d\n", ret);
diff --git a/drivers/core/Makefile b/drivers/core/Makefile
index 1dd25a3..11e0276 100644
--- a/drivers/core/Makefile
+++ b/drivers/core/Makefile
@@ -7,7 +7,7 @@
obj-y += device.o lists.o root.o uclass.o util.o
obj-$(CONFIG_DEVRES) += devres.o
ifndef CONFIG_SPL_BUILD
-obj-$(CONFIG_OF_CONTROL) += simple-bus.o
+obj-$(CONFIG_$(SPL_)OF_CONTROL) += simple-bus.o
endif
obj-$(CONFIG_$(SPL_)DM_DEVICE_REMOVE) += device-remove.o
obj-$(CONFIG_DM) += dump.o
diff --git a/drivers/core/device.c b/drivers/core/device.c
index 56b9081..e23a872 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -59,7 +59,7 @@ int device_bind(struct udevice *parent, const struct driver *drv,

dev->seq = -1;
dev->req_seq = -1;
- if (IS_ENABLED(CONFIG_OF_CONTROL) && IS_ENABLED(CONFIG_DM_SEQ_ALIAS)) {
+ if (CONFIG_IS_ENABLED(OF_CONTROL) && IS_ENABLED(CONFIG_DM_SEQ_ALIAS)) {
/*
* Some devices, such as a SPI bus, I2C bus and serial ports
* are numbered using aliases.
@@ -561,7 +561,7 @@ const char *dev_get_uclass_name(struct udevice *dev)

fdt_addr_t dev_get_addr(struct udevice *dev)
{
-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
fdt_addr_t addr;

addr = fdtdec_get_addr(gd->fdt_blob, dev->of_offset, "reg");
diff --git a/drivers/core/lists.c b/drivers/core/lists.c
index 2e52500..a1c9478 100644
--- a/drivers/core/lists.c
+++ b/drivers/core/lists.c
@@ -99,7 +99,7 @@ int device_bind_driver_to_node(struct udevice *parent, const char *drv_name,
return 0;
}

-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
/**
* driver_check_compatible() - Check if a driver is compatible with this node
*
diff --git a/drivers/core/root.c b/drivers/core/root.c
index 12d0460..78ab00c 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -114,7 +114,7 @@ int dm_init(void)
ret = device_bind_by_name(NULL, false, &root_info, &DM_ROOT_NON_CONST);
if (ret)
return ret;
-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
DM_ROOT_NON_CONST->of_offset = 0;
#endif
ret = device_probe(DM_ROOT_NON_CONST);
@@ -145,7 +145,7 @@ int dm_scan_platdata(bool pre_reloc_only)
return ret;
}

-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
int dm_scan_fdt_node(struct udevice *parent, const void *blob, int offset,
bool pre_reloc_only)
{
@@ -198,7 +198,7 @@ int dm_init_and_scan(bool pre_reloc_only)
return ret;
}

- if (OF_CONTROL) {
+ if (CONFIG_IS_ENABLED(OF_CONTROL)) {
ret = dm_scan_fdt(gd->fdt_blob, pre_reloc_only);
if (ret) {
debug("dm_scan_fdt() failed: %d\n", ret);
diff --git a/drivers/gpio/mxc_gpio.c b/drivers/gpio/mxc_gpio.c
index 57a650f..0c48320 100644
--- a/drivers/gpio/mxc_gpio.c
+++ b/drivers/gpio/mxc_gpio.c
@@ -336,7 +336,7 @@ U_BOOT_DRIVER(gpio_mxc) = {
.bind = mxc_gpio_bind,
};

-#ifndef CONFIG_OF_CONTROL
+#if !CONFIG_IS_ENABLED(OF_CONTROL)
static const struct mxc_gpio_plat mxc_plat[] = {
{ 0, (struct gpio_regs *)GPIO1_BASE_ADDR },
{ 1, (struct gpio_regs *)GPIO2_BASE_ADDR },
diff --git a/drivers/gpio/vybrid_gpio.c b/drivers/gpio/vybrid_gpio.c
index 6eaf0a9..4d25f9a 100644
--- a/drivers/gpio/vybrid_gpio.c
+++ b/drivers/gpio/vybrid_gpio.c
@@ -135,7 +135,7 @@ static int vybrid_gpio_bind(struct udevice *dev)
return 0;
}

-#ifndef CONFIG_OF_CONTROL
+#if !CONFIG_IS_ENABLED(OF_CONTROL)
static const struct vybrid_gpio_platdata vybrid_gpio[] = {
{0, GPIO0_BASE_ADDR, "GPIO0 "},
{1, GPIO1_BASE_ADDR, "GPIO1 "},
diff --git a/drivers/i2c/s3c24x0_i2c.c b/drivers/i2c/s3c24x0_i2c.c
index c11a6be..ae6f436 100644
--- a/drivers/i2c/s3c24x0_i2c.c
+++ b/drivers/i2c/s3c24x0_i2c.c
@@ -1002,7 +1002,7 @@ static int s3c24x0_i2c_write(struct i2c_adapter *adap, uchar chip, uint addr,
}
}

-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
static void process_nodes(const void *blob, int node_list[], int count,
int is_highspeed)
{
@@ -1101,7 +1101,7 @@ int i2c_reset_port_fdt(const void *blob, int node)

return 0;
}
-#endif /* CONFIG_OF_CONTROL */
+#endif /* CONFIG_IS_ENABLED(OF_CONTROL) */

#ifdef CONFIG_EXYNOS5
static void exynos_i2c_init(struct i2c_adapter *adap, int speed, int slaveaddr)
diff --git a/drivers/input/Makefile b/drivers/input/Makefile
index a8e9be2..b804236 100644
--- a/drivers/input/Makefile
+++ b/drivers/input/Makefile
@@ -13,4 +13,4 @@ obj-y += keyboard.o pc_keyb.o
obj-$(CONFIG_PS2MULT) += ps2mult.o ps2ser.o
endif
obj-y += input.o
-obj-$(CONFIG_OF_CONTROL) += key_matrix.o
+obj-$(CONFIG_$(SPL_)OF_CONTROL) += key_matrix.o
diff --git a/drivers/input/tegra-kbc.c b/drivers/input/tegra-kbc.c
index 0ef94f7..c9c9fac 100644
--- a/drivers/input/tegra-kbc.c
+++ b/drivers/input/tegra-kbc.c
@@ -295,7 +295,7 @@ static int init_tegra_keyboard(struct stdio_dev *dev)
if (config.created)
return 0;

-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
int node;

node = fdtdec_next_compatible(gd->fdt_blob, 0,
diff --git a/drivers/mmc/exynos_dw_mmc.c b/drivers/mmc/exynos_dw_mmc.c
index e083745..cde2ba7 100644
--- a/drivers/mmc/exynos_dw_mmc.c
+++ b/drivers/mmc/exynos_dw_mmc.c
@@ -158,7 +158,7 @@ int exynos_dwmci_add_port(int index, u32 regbase, int bus_width, u32 clksel)
return exynos_dwmci_core_init(host, index);
}

-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
static struct dwmci_host dwmci_host[DWMMC_MAX_CH_NUM];

static int do_dwmci_init(struct dwmci_host *host)
diff --git a/drivers/mmc/s5p_sdhci.c b/drivers/mmc/s5p_sdhci.c
index 522eab9..4db51d6 100644
--- a/drivers/mmc/s5p_sdhci.c
+++ b/drivers/mmc/s5p_sdhci.c
@@ -96,7 +96,7 @@ int s5p_sdhci_init(u32 regbase, int index, int bus_width)
return s5p_sdhci_core_init(host);
}

-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
struct sdhci_host sdhci_host[SDHCI_MAX_HOSTS];

static int do_sdhci_init(struct sdhci_host *host)
diff --git a/drivers/mmc/tegra_mmc.c b/drivers/mmc/tegra_mmc.c
index 6f8b4d0..1584865 100644
--- a/drivers/mmc/tegra_mmc.c
+++ b/drivers/mmc/tegra_mmc.c
@@ -21,7 +21,7 @@ DECLARE_GLOBAL_DATA_PTR;

struct mmc_host mmc_host[CONFIG_SYS_MMC_MAX_DEVICE];

-#ifndef CONFIG_OF_CONTROL
+#if !CONFIG_IS_ENABLED(OF_CONTROL)
#error "Please enable device tree support to use this driver"
#endif

diff --git a/drivers/mmc/zynq_sdhci.c b/drivers/mmc/zynq_sdhci.c
index 971acbb..c69f5d4 100644
--- a/drivers/mmc/zynq_sdhci.c
+++ b/drivers/mmc/zynq_sdhci.c
@@ -33,7 +33,7 @@ int zynq_sdhci_init(phys_addr_t regbase)
return 0;
}

-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
int zynq_sdhci_of_init(const void *blob)
{
int offset = 0;
diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c
index e0283dc..954376d 100644
--- a/drivers/mtd/spi/sf_probe.c
+++ b/drivers/mtd/spi/sf_probe.c
@@ -266,7 +266,7 @@ static int spi_flash_validate_params(struct spi_slave *spi, u8 *idcode,
return 0;
}

-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
int spi_flash_decode_fdt(const void *blob, struct spi_flash *flash)
{
fdt_addr_t addr;
@@ -292,7 +292,7 @@ int spi_flash_decode_fdt(const void *blob, struct spi_flash *flash)

return 0;
}
-#endif /* CONFIG_OF_CONTROL */
+#endif /* CONFIG_IS_ENABLED(OF_CONTROL) */

/**
* spi_flash_probe_slave() - Probe for a SPI flash device on a bus
@@ -347,7 +347,7 @@ int spi_flash_probe_slave(struct spi_slave *spi, struct spi_flash *flash)
}
}

-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
if (spi_flash_decode_fdt(gd->fdt_blob, flash)) {
debug("SF: FDT decode error\n");
ret = -EINVAL;
diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c
index c9afa99..564205d 100644
--- a/drivers/net/xilinx_emaclite.c
+++ b/drivers/net/xilinx_emaclite.c
@@ -361,7 +361,7 @@ int xilinx_emaclite_initialize(bd_t *bis, unsigned long base_addr,
return 1;
}

-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
int xilinx_emaclite_of_init(const void *blob)
{
int offset = 0;
diff --git a/drivers/net/zynq_gem.c b/drivers/net/zynq_gem.c
index b2006df..9175d2c 100644
--- a/drivers/net/zynq_gem.c
+++ b/drivers/net/zynq_gem.c
@@ -553,7 +553,7 @@ int zynq_gem_initialize(bd_t *bis, phys_addr_t base_addr,
return 1;
}

-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
int zynq_gem_of_init(const void *blob)
{
int offset = 0;
diff --git a/drivers/power/exynos-tmu.c b/drivers/power/exynos-tmu.c
index 9a093a5..b9968c2 100644
--- a/drivers/power/exynos-tmu.c
+++ b/drivers/power/exynos-tmu.c
@@ -180,7 +180,7 @@ enum tmu_status_t tmu_monitor(int *temp)
*/
static int get_tmu_fdt_values(struct tmu_info *info, const void *blob)
{
-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
fdt_addr_t addr;
int node;
int error = 0;
diff --git a/drivers/power/pmic/pmic_max77686.c b/drivers/power/pmic/pmic_max77686.c
index 1ad810a..93c8d2b 100644
--- a/drivers/power/pmic/pmic_max77686.c
+++ b/drivers/power/pmic/pmic_max77686.c
@@ -256,7 +256,7 @@ int pmic_init(unsigned char bus)
{
static const char name[] = "MAX77686_PMIC";
struct pmic *p = pmic_alloc();
-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
const void *blob = gd->fdt_blob;
int node, parent, tmp;
#endif
@@ -266,7 +266,7 @@ int pmic_init(unsigned char bus)
return -ENOMEM;
}

-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
node = fdtdec_next_compatible(blob, 0, COMPAT_MAXIM_MAX77686_PMIC);
if (node < 0) {
debug("PMIC: No node for PMIC Chip in device tree\n");
diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
index c8a77e2..2b6d1e4 100644
--- a/drivers/serial/ns16550.c
+++ b/drivers/serial/ns16550.c
@@ -357,7 +357,7 @@ int ns16550_serial_probe(struct udevice *dev)
return 0;
}

-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
int ns16550_serial_ofdata_to_platdata(struct udevice *dev)
{
struct ns16550_platdata *plat = dev->platdata;
diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
index bbc366b..bca296c 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -32,7 +32,7 @@ static void serial_find_console_or_panic(void)
struct udevice *dev;
int node;

- if (OF_CONTROL && gd->fdt_blob) {
+ if (CONFIG_IS_ENABLED(OF_CONTROL) && gd->fdt_blob) {
/* Check for a chosen console */
node = fdtdec_get_chosen_node(gd->fdt_blob, "stdout-path");
if (node < 0)
@@ -55,7 +55,7 @@ static void serial_find_console_or_panic(void)
}
}
}
- if (!SPL_BUILD || !OF_CONTROL || !gd->fdt_blob) {
+ if (!SPL_BUILD || !CONFIG_IS_ENABLED(OF_CONTROL) || !gd->fdt_blob) {
/*
* Try to use CONFIG_CONS_INDEX if available (it is numbered
* from 1!).
diff --git a/drivers/serial/serial_omap.c b/drivers/serial/serial_omap.c
index 265fe00..36c8faf 100644
--- a/drivers/serial/serial_omap.c
+++ b/drivers/serial/serial_omap.c
@@ -12,7 +12,7 @@

DECLARE_GLOBAL_DATA_PTR;

-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
static const struct udevice_id omap_serial_ids[] = {
{ .compatible = "ti,omap3-uart" },
{ }
diff --git a/drivers/serial/serial_pl01x.c b/drivers/serial/serial_pl01x.c
index ad503af..917b603 100644
--- a/drivers/serial/serial_pl01x.c
+++ b/drivers/serial/serial_pl01x.c
@@ -353,7 +353,7 @@ static const struct dm_serial_ops pl01x_serial_ops = {
.setbrg = pl01x_serial_setbrg,
};

-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
static const struct udevice_id pl01x_serial_id[] ={
{.compatible = "arm,pl011", .data = TYPE_PL011},
{.compatible = "arm,pl010", .data = TYPE_PL010},
diff --git a/drivers/serial/serial_tegra.c b/drivers/serial/serial_tegra.c
index b9227f0..0c84f0b 100644
--- a/drivers/serial/serial_tegra.c
+++ b/drivers/serial/serial_tegra.c
@@ -9,7 +9,7 @@
#include <ns16550.h>
#include <serial.h>

-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
static const struct udevice_id tegra_serial_ids[] = {
{ .compatible = "nvidia,tegra20-uart" },
{ }
@@ -42,7 +42,7 @@ U_BOOT_DEVICE(ns16550_serial) = {
U_BOOT_DRIVER(serial_ns16550) = {
.name = "serial_tegra20",
.id = UCLASS_SERIAL,
-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
.of_match = tegra_serial_ids,
.ofdata_to_platdata = tegra_serial_ofdata_to_platdata,
.platdata_auto_alloc_size = sizeof(struct ns16550_platdata),
diff --git a/drivers/serial/serial_uniphier.c b/drivers/serial/serial_uniphier.c
index f210986..abf362a 100644
--- a/drivers/serial/serial_uniphier.c
+++ b/drivers/serial/serial_uniphier.c
@@ -113,7 +113,7 @@ static int uniphier_serial_remove(struct udevice *dev)
return 0;
}

-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
static const struct udevice_id uniphier_uart_of_match[] = {
{ .compatible = "socionext,uniphier-uart" },
{ /* sentinel */ }
diff --git a/drivers/serial/serial_zynq.c b/drivers/serial/serial_zynq.c
index 9278763..9d84290 100644
--- a/drivers/serial/serial_zynq.c
+++ b/drivers/serial/serial_zynq.c
@@ -175,7 +175,7 @@ DECLARE_PSSERIAL_FUNCTIONS(1);
static struct serial_device uart_zynq_serial1_device =
INIT_PSSERIAL_STRUCTURE(1, "ttyPS1");

-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
__weak struct serial_device *default_serial_console(void)
{
const void *blob = gd->fdt_blob;
diff --git a/drivers/sound/max98095.c b/drivers/sound/max98095.c
index febf419..35829f8 100644
--- a/drivers/sound/max98095.c
+++ b/drivers/sound/max98095.c
@@ -520,7 +520,7 @@ static int get_max98095_codec_values(struct sound_codec_info *pcodec_info,
const void *blob)
{
int error = 0;
-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
enum fdt_compat_id compat;
int node;
int parent;
diff --git a/drivers/sound/wm8994.c b/drivers/sound/wm8994.c
index f8e9a6e..d378442 100644
--- a/drivers/sound/wm8994.c
+++ b/drivers/sound/wm8994.c
@@ -814,7 +814,7 @@ static int get_codec_values(struct sound_codec_info *pcodec_info,
const void *blob)
{
int error = 0;
-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
enum fdt_compat_id compat;
int node;
int parent;
diff --git a/drivers/tpm/tpm_tis_i2c.c b/drivers/tpm/tpm_tis_i2c.c
index ee4dfea..cc740e9 100644
--- a/drivers/tpm/tpm_tis_i2c.c
+++ b/drivers/tpm/tpm_tis_i2c.c
@@ -585,7 +585,7 @@ static struct tpm_vendor_specific tpm_tis_i2c = {

static enum i2c_chip_type tpm_vendor_chip_type(void)
{
-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
const void *blob = gd->fdt_blob;

if (fdtdec_next_compatible(blob, 0, COMPAT_INFINEON_SLB9645_TPM) >= 0)
diff --git a/drivers/video/exynos_dp_lowlevel.c b/drivers/video/exynos_dp_lowlevel.c
index 05118f8..e9b461a 100644
--- a/drivers/video/exynos_dp_lowlevel.c
+++ b/drivers/video/exynos_dp_lowlevel.c
@@ -22,7 +22,7 @@ struct exynos_dp *dp_regs;

void exynos_dp_set_base_addr(void)
{
-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
unsigned int node = fdtdec_next_compatible(gd->fdt_blob,
0, COMPAT_SAMSUNG_EXYNOS5_DP);
if (node <= 0)
diff --git a/drivers/video/exynos_fb.c b/drivers/video/exynos_fb.c
index 8f3b826..69edc3a 100644
--- a/drivers/video/exynos_fb.c
+++ b/drivers/video/exynos_fb.c
@@ -28,7 +28,7 @@ DECLARE_GLOBAL_DATA_PTR;

static unsigned int panel_width, panel_height;

-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
vidinfo_t panel_info = {
/*
* Insert a value here so that we don't end up in the BSS
@@ -126,7 +126,7 @@ static void lcd_panel_on(vidinfo_t *vid)

exynos_backlight_on(1);

-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
node = fdtdec_next_compatible(gd->fdt_blob, 0,
COMPAT_SAMSUNG_EXYNOS_FIMD);
if (node <= 0) {
@@ -150,7 +150,7 @@ static void lcd_panel_on(vidinfo_t *vid)
exynos_mipi_dsi_init();
}

-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
int exynos_lcd_early_init(const void *blob)
{
unsigned int node;
@@ -295,7 +295,7 @@ void lcd_ctrl_init(void *lcdbase)
set_system_display_ctrl();
set_lcd_clk();

-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
#ifdef CONFIG_EXYNOS_MIPI_DSIM
exynos_init_dsim_platform_data(&panel_info);
#endif
diff --git a/drivers/video/exynos_fimd.c b/drivers/video/exynos_fimd.c
index f67fa81..ac001a8 100644
--- a/drivers/video/exynos_fimd.c
+++ b/drivers/video/exynos_fimd.c
@@ -251,7 +251,7 @@ void exynos_fimd_window_off(unsigned int win_id)
writel(cfg, &fimd_ctrl->winshmap);
}

-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
/*
* The reset value for FIMD SYSMMU register MMU_CTRL is 3
* on Exynos5420 and newer versions.
@@ -295,7 +295,7 @@ void exynos_fimd_lcd_init(vidinfo_t *vid)
{
unsigned int cfg = 0, rgb_mode;
unsigned int offset;
-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
unsigned int node;

node = fdtdec_next_compatible(gd->fdt_blob,
diff --git a/drivers/video/exynos_mipi_dsi.c b/drivers/video/exynos_mipi_dsi.c
index c68ebd6..b597acc 100644
--- a/drivers/video/exynos_mipi_dsi.c
+++ b/drivers/video/exynos_mipi_dsi.c
@@ -28,7 +28,7 @@
DECLARE_GLOBAL_DATA_PTR;

static struct exynos_platform_mipi_dsim *dsim_pd;
-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
static struct mipi_dsim_config dsim_config_dt;
static struct exynos_platform_mipi_dsim dsim_platform_data_dt;
static struct mipi_dsim_lcd_device mipi_lcd_device_dt;
@@ -249,7 +249,7 @@ void exynos_set_dsim_platform_data(struct exynos_platform_mipi_dsim *pd)
dsim_pd = pd;
}

-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
int exynos_dsim_config_parse_dt(const void *blob)
{
int node;
diff --git a/drivers/video/tegra.c b/drivers/video/tegra.c
index 33c6103..8e81346 100644
--- a/drivers/video/tegra.c
+++ b/drivers/video/tegra.c
@@ -49,7 +49,7 @@ vidinfo_t panel_info = {
.vl_col = -1,
};

-#ifndef CONFIG_OF_CONTROL
+#if !CONFIG_IS_ENABLED(OF_CONTROL)
#error "You must enable CONFIG_OF_CONTROL to get Tegra LCD support"
#endif

diff --git a/include/cli.h b/include/cli.h
index 6da7a4a..4c39b9e 100644
--- a/include/cli.h
+++ b/include/cli.h
@@ -108,7 +108,7 @@ int cli_readline_into_buffer(const char *const prompt, char *buffer,
*/
int cli_simple_parse_line(char *line, char *argv[]);

-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
/**
* cli_process_fdt() - process the boot command from the FDT
*
diff --git a/include/config_uncmd_spl.h b/include/config_uncmd_spl.h
index 2741fc8..6e299f6 100644
--- a/include/config_uncmd_spl.h
+++ b/include/config_uncmd_spl.h
@@ -20,9 +20,6 @@
#undef CONFIG_CMD_SNTP
#undef CONFIG_CMD_TFTPPUT
#undef CONFIG_CMD_TFTPSRV
-#ifndef CONFIG_SPL_OF_CONTROL
-#undef CONFIG_OF_CONTROL
-#endif

#ifndef CONFIG_SPL_DM
#undef CONFIG_DM_SERIAL
diff --git a/include/configs/microblaze-generic.h b/include/configs/microblaze-generic.h
index e16965c..f98a357 100644
--- a/include/configs/microblaze-generic.h
+++ b/include/configs/microblaze-generic.h
@@ -106,7 +106,8 @@
# define CONFIG_XILINX_TB_WATCHDOG
#endif

-#ifndef CONFIG_OF_CONTROL
+#if !defined(CONFIG_OF_CONTROL) || \
+ (defined(CONFIG_SPL_BUILD) && !defined(CONFIG_SPL_OF_CONTROL))
/* ddr sdram - main memory */
# define CONFIG_SYS_SDRAM_BASE XILINX_RAM_START
# define CONFIG_SYS_SDRAM_SIZE XILINX_RAM_SIZE
diff --git a/include/configs/socfpga_common.h b/include/configs/socfpga_common.h
index 5ca45a9..c64c7ed 100644
--- a/include/configs/socfpga_common.h
+++ b/include/configs/socfpga_common.h
@@ -214,7 +214,7 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
#define CONFIG_SPI_FLASH_BAR
#endif

-#ifdef CONFIG_OF_CONTROL /* DW SPI is controlled via DT */
+#if CONFIG_IS_ENABLED(OF_CONTROL) /* DW SPI is controlled via DT */
#define CONFIG_DESIGNWARE_SPI
#define CONFIG_CMD_SPI
#endif
diff --git a/include/dm/device.h b/include/dm/device.h
index 1f78963..a239be6 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -122,11 +122,11 @@ struct udevice_id {
ulong data;
};

-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
#define of_match_ptr(_ptr) (_ptr)
#else
#define of_match_ptr(_ptr) NULL
-#endif /* CONFIG_OF_CONTROL */
+#endif /* CONFIG_IS_ENABLED(OF_CONTROL) */

/**
* struct driver - A driver for a feature or peripheral
diff --git a/include/fdtdec.h b/include/fdtdec.h
index 372baec..f34b923 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -45,16 +45,6 @@ struct fdt_memory {
#define SPL_BUILD 0
#endif

-#ifdef CONFIG_OF_CONTROL
-# if defined(CONFIG_SPL_BUILD) && !defined(CONFIG_SPL_OF_CONTROL)
-# define OF_CONTROL 0
-# else
-# define OF_CONTROL 1
-# endif
-#else
-# define OF_CONTROL 0
-#endif
-
/*
* Information about a resource. start is the first address of the resource
* and end is the last address (inclusive). The length of the resource will
diff --git a/lib/Makefile b/lib/Makefile
index 3b6a74b..96f832e 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -26,8 +26,8 @@ obj-y += crc8.o
obj-y += crc16.o
obj-$(CONFIG_ERRNO_STR) += errno_str.o
obj-$(CONFIG_FIT) += fdtdec_common.o
-obj-$(CONFIG_OF_CONTROL) += fdtdec_common.o
-obj-$(CONFIG_OF_CONTROL) += fdtdec.o
+obj-$(CONFIG_$(SPL_)OF_CONTROL) += fdtdec_common.o
+obj-$(CONFIG_$(SPL_)OF_CONTROL) += fdtdec.o
obj-$(CONFIG_TEST_FDTDEC) += fdtdec_test.o
obj-$(CONFIG_GZIP) += gunzip.o
obj-$(CONFIG_GZIP_COMPRESSED) += gzip.o
@@ -51,15 +51,12 @@ endif

ifndef CONFIG_SPL_BUILD
obj-$(CONFIG_OF_LIBFDT) += libfdt/
-obj-$(CONFIG_OF_CONTROL) += fdtdec_common.o
-obj-$(CONFIG_OF_CONTROL) += fdtdec.o
endif
-
ifdef CONFIG_SPL_OF_CONTROL
obj-$(CONFIG_OF_LIBFDT) += libfdt/
-obj-$(CONFIG_OF_CONTROL) += fdtdec_common.o
-obj-$(CONFIG_OF_CONTROL) += fdtdec.o
endif
+obj-$(CONFIG_$(SPL_)OF_CONTROL) += fdtdec_common.o
+obj-$(CONFIG_$(SPL_)OF_CONTROL) += fdtdec.o

ifdef CONFIG_SPL_BUILD
obj-$(CONFIG_SPL_YMODEM_SUPPORT) += crc16.o
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index b201787..5a93cc2 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -1154,7 +1154,7 @@ int fdtdec_decode_display_timing(const void *blob, int parent, int index,

int fdtdec_setup(void)
{
-#ifdef CONFIG_OF_CONTROL
+#if CONFIG_IS_ENABLED(OF_CONTROL)
# ifdef CONFIG_OF_EMBED
/* Get a pointer to the FDT */
gd->fdt_blob = __dtb_dt_begin;
diff --git a/scripts/Makefile.uncmd_spl b/scripts/Makefile.uncmd_spl
index b90fcb8..4003546 100644
--- a/scripts/Makefile.uncmd_spl
+++ b/scripts/Makefile.uncmd_spl
@@ -3,9 +3,6 @@
# TODO: Invent a better way

ifdef CONFIG_SPL_BUILD
-ifndef CONFIG_SPL_OF_CONTROL
-CONFIG_OF_CONTROL=
-endif

ifndef CONFIG_SPL_DM
CONFIG_DM_SERIAL=
--
1.9.1