]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
treewide: Try to avoid the preprocessor with OF_REAL
authorSimon Glass <sjg@chromium.org>
Sat, 7 Aug 2021 13:24:06 +0000 (07:24 -0600)
committerSimon Glass <sjg@chromium.org>
Sat, 25 Sep 2021 15:46:15 +0000 (09:46 -0600)
Convert some of these occurences to C code, where it is easy to do. This
should help encourage this approach to be used in new code.

Signed-off-by: Simon Glass <sjg@chromium.org>
21 files changed:
arch/x86/cpu/intel_common/p2sb.c
doc/develop/driver-model/of-plat.rst
drivers/clk/clk_fixed_factor.c
drivers/clk/clk_fixed_rate.c
drivers/clk/rockchip/clk_rk3188.c
drivers/clk/rockchip/clk_rk3288.c
drivers/clk/rockchip/clk_rk3368.c
drivers/clk/rockchip/clk_rk3399.c
drivers/misc/p2sb-uclass.c
drivers/mmc/fsl_esdhc_imx.c
drivers/mmc/ftsdc010_mci.c
drivers/mmc/rockchip_dw_mmc.c
drivers/ram/rockchip/dmc-rk3368.c
drivers/ram/rockchip/sdram_rk3188.c
drivers/ram/rockchip/sdram_rk322x.c
drivers/ram/rockchip/sdram_rk3288.c
drivers/ram/rockchip/sdram_rk3399.c
drivers/spi/rk_spi.c
drivers/spi/spi-uclass.c
drivers/timer/rockchip_timer.c
drivers/timer/timer-uclass.c

index 5dc816396e57d435e1de6360f1a28063af2126a7..5a7b30d94a1f75d5b57afc27b83ad6df57e704fc 100644 (file)
@@ -159,16 +159,16 @@ static int p2sb_remove(struct udevice *dev)
 
 static int p2sb_child_post_bind(struct udevice *dev)
 {
-#if CONFIG_IS_ENABLED(OF_REAL)
-       struct p2sb_child_plat *pplat = dev_get_parent_plat(dev);
-       int ret;
-       u32 pid;
-
-       ret = dev_read_u32(dev, "intel,p2sb-port-id", &pid);
-       if (ret)
-               return ret;
-       pplat->pid = pid;
-#endif
+       if (CONFIG_IS_ENABLED(OF_REAL)) {
+               struct p2sb_child_plat *pplat = dev_get_parent_plat(dev);
+               int ret;
+               u32 pid;
+
+               ret = dev_read_u32(dev, "intel,p2sb-port-id", &pid);
+               if (ret)
+                       return ret;
+               pplat->pid = pid;
+       }
 
        return 0;
 }
index 8b16f553017f87c157624b360bdd870761304f58..507731a170afbeb71cfcaaaa7cfdf0fec29e3036 100644 (file)
@@ -215,16 +215,16 @@ For example:
 
     static int mmc_of_to_plat(struct udevice *dev)
     {
-    #if CONFIG_IS_ENABLED(OF_REAL)
+        if (CONFIG_IS_ENABLED(OF_REAL)) {
             /* Decode the devicetree data */
             struct mmc_plat *plat = dev_get_plat(dev);
             const void *blob = gd->fdt_blob;
             int node = dev_of_offset(dev);
 
             plat->fifo_depth = fdtdec_get_int(blob, node, "fifo-depth", 0);
-    #endif
+        }
 
-            return 0;
+        return 0;
     }
 
     static int mmc_probe(struct udevice *dev)
index 04871b4744de467b4b6874c1dfc0c0b05f00ad00..41b0d9c0603ed9929e955b37b0450c1785a94e9a 100644 (file)
@@ -40,17 +40,17 @@ const struct clk_ops clk_fixed_factor_ops = {
 
 static int clk_fixed_factor_of_to_plat(struct udevice *dev)
 {
-#if CONFIG_IS_ENABLED(OF_REAL)
-       int err;
-       struct clk_fixed_factor *ff = to_clk_fixed_factor(dev);
+       if (CONFIG_IS_ENABLED(OF_REAL)) {
+               int err;
+               struct clk_fixed_factor *ff = to_clk_fixed_factor(dev);
 
-       err = clk_get_by_index(dev, 0, &ff->parent);
-       if (err)
-               return err;
+               err = clk_get_by_index(dev, 0, &ff->parent);
+               if (err)
+                       return err;
 
-       ff->div = dev_read_u32_default(dev, "clock-div", 1);
-       ff->mult = dev_read_u32_default(dev, "clock-mult", 1);
-#endif
+               ff->div = dev_read_u32_default(dev, "clock-div", 1);
+               ff->mult = dev_read_u32_default(dev, "clock-mult", 1);
+       }
 
        return 0;
 }
index d0f25941d0a964e3796960f8c68aabb6a2037cfe..e0dc4ab85f8153c5b9bd462796c7a100654dd891 100644 (file)
@@ -32,9 +32,10 @@ void clk_fixed_rate_ofdata_to_plat_(struct udevice *dev,
                                    struct clk_fixed_rate *plat)
 {
        struct clk *clk = &plat->clk;
-#if CONFIG_IS_ENABLED(OF_REAL)
-       plat->fixed_rate = dev_read_u32_default(dev, "clock-frequency", 0);
-#endif
+       if (CONFIG_IS_ENABLED(OF_REAL))
+               plat->fixed_rate = dev_read_u32_default(dev, "clock-frequency",
+                                                       0);
+
        /* Make fixed rate clock accessible from higher level struct clk */
        /* FIXME: This is not allowed */
        dev_set_uclass_priv(dev, clk);
index 1751672f640cce8a5785f89ffe644a0f16d9f6c2..038cb55965e89bfa012642da708d6713b53c7c53 100644 (file)
@@ -540,11 +540,11 @@ static struct clk_ops rk3188_clk_ops = {
 
 static int rk3188_clk_of_to_plat(struct udevice *dev)
 {
-#if CONFIG_IS_ENABLED(OF_REAL)
-       struct rk3188_clk_priv *priv = dev_get_priv(dev);
+       if (CONFIG_IS_ENABLED(OF_REAL)) {
+               struct rk3188_clk_priv *priv = dev_get_priv(dev);
 
-       priv->cru = dev_read_addr_ptr(dev);
-#endif
+               priv->cru = dev_read_addr_ptr(dev);
+       }
 
        return 0;
 }
index ee222217a536c65e53dba5d8ff236fe943bee6bf..3b29992c3e59385039f903d151c1883cec457853 100644 (file)
@@ -957,11 +957,11 @@ static struct clk_ops rk3288_clk_ops = {
 
 static int rk3288_clk_of_to_plat(struct udevice *dev)
 {
-#if CONFIG_IS_ENABLED(OF_REAL)
-       struct rk3288_clk_priv *priv = dev_get_priv(dev);
+       if (CONFIG_IS_ENABLED(OF_REAL)) {
+               struct rk3288_clk_priv *priv = dev_get_priv(dev);
 
-       priv->cru = dev_read_addr_ptr(dev);
-#endif
+               priv->cru = dev_read_addr_ptr(dev);
+       }
 
        return 0;
 }
index d0d0046eb1e26fdddea26e2e73620825e96fe6ca..39caf23c31fc7e7ce92f8d672f4b629e6c8b0821 100644 (file)
@@ -596,11 +596,11 @@ static int rk3368_clk_probe(struct udevice *dev)
 
 static int rk3368_clk_of_to_plat(struct udevice *dev)
 {
-#if CONFIG_IS_ENABLED(OF_REAL)
-       struct rk3368_clk_priv *priv = dev_get_priv(dev);
+       if (CONFIG_IS_ENABLED(OF_REAL)) {
+               struct rk3368_clk_priv *priv = dev_get_priv(dev);
 
-       priv->cru = dev_read_addr_ptr(dev);
-#endif
+               priv->cru = dev_read_addr_ptr(dev);
+       }
 
        return 0;
 }
index 209c726a4de4602502dbb5fd4af6ac2cdafb6973..7d31a9f22a85fdb0673922eba9734cf9af238b0a 100644 (file)
@@ -1402,11 +1402,12 @@ static int rk3399_clk_probe(struct udevice *dev)
 
 static int rk3399_clk_of_to_plat(struct udevice *dev)
 {
-#if CONFIG_IS_ENABLED(OF_REAL)
-       struct rk3399_clk_priv *priv = dev_get_priv(dev);
+       if (CONFIG_IS_ENABLED(OF_REAL)) {
+               struct rk3399_clk_priv *priv = dev_get_priv(dev);
+
+               priv->cru = dev_read_addr_ptr(dev);
+       }
 
-       priv->cru = dev_read_addr_ptr(dev);
-#endif
        return 0;
 }
 
@@ -1614,11 +1615,12 @@ static int rk3399_pmuclk_probe(struct udevice *dev)
 
 static int rk3399_pmuclk_of_to_plat(struct udevice *dev)
 {
-#if CONFIG_IS_ENABLED(OF_REAL)
-       struct rk3399_pmuclk_priv *priv = dev_get_priv(dev);
+       if (CONFIG_IS_ENABLED(OF_REAL)) {
+               struct rk3399_pmuclk_priv *priv = dev_get_priv(dev);
+
+               priv->pmucru = dev_read_addr_ptr(dev);
+       }
 
-       priv->pmucru = dev_read_addr_ptr(dev);
-#endif
        return 0;
 }
 
index 98d58b37c28ce5552589b69656d6b39d151f96a6..f24857a1515e27201ab9a642498864a43d84e701 100644 (file)
@@ -183,16 +183,16 @@ int p2sb_set_port_id(struct udevice *dev, int portid)
 
 static int p2sb_child_post_bind(struct udevice *dev)
 {
-#if CONFIG_IS_ENABLED(OF_REAL)
-       struct p2sb_child_plat *pplat = dev_get_parent_plat(dev);
-       int ret;
-       u32 pid;
-
-       ret = dev_read_u32(dev, "intel,p2sb-port-id", &pid);
-       if (ret)
-               return ret;
-       pplat->pid = pid;
-#endif
+       if (CONFIG_IS_ENABLED(OF_REAL)) {
+               struct p2sb_child_plat *pplat = dev_get_parent_plat(dev);
+               int ret;
+               u32 pid;
+
+               ret = dev_read_u32(dev, "intel,p2sb-port-id", &pid);
+               if (ret)
+                       return ret;
+               pplat->pid = pid;
+       }
 
        return 0;
 }
index 2f6156e039cc8a70665a41a028d3e90693831596..5dfd484ef9a4a82fa1adbb490ee5454058ab5ea7 100644 (file)
@@ -1411,7 +1411,6 @@ __weak void init_clk_usdhc(u32 index)
 
 static int fsl_esdhc_of_to_plat(struct udevice *dev)
 {
-#if CONFIG_IS_ENABLED(OF_REAL)
        struct fsl_esdhc_priv *priv = dev_get_priv(dev);
 #if CONFIG_IS_ENABLED(DM_REGULATOR)
        struct udevice *vqmmc_dev;
@@ -1419,10 +1418,12 @@ static int fsl_esdhc_of_to_plat(struct udevice *dev)
 #endif
        const void *fdt = gd->fdt_blob;
        int node = dev_of_offset(dev);
-
        fdt_addr_t addr;
        unsigned int val;
 
+       if (!CONFIG_IS_ENABLED(OF_REAL))
+               return 0;
+
        addr = dev_read_addr(dev);
        if (addr == FDT_ADDR_T_NONE)
                return -EINVAL;
@@ -1494,7 +1495,7 @@ static int fsl_esdhc_of_to_plat(struct udevice *dev)
                        priv->vs18_enable = 1;
        }
 #endif
-#endif
+
        return 0;
 }
 
@@ -1598,11 +1599,11 @@ static int fsl_esdhc_probe(struct udevice *dev)
                return ret;
        }
 
-#if CONFIG_IS_ENABLED(OF_REAL)
-       ret = mmc_of_parse(dev, &plat->cfg);
-       if (ret)
-               return ret;
-#endif
+       if (CONFIG_IS_ENABLED(OF_REAL)) {
+               ret = mmc_of_parse(dev, &plat->cfg);
+               if (ret)
+                       return ret;
+       }
 
        mmc = &plat->mmc;
        mmc->cfg = &plat->cfg;
index b30da5b72a4259e0a24c89e02d7f3ba91df8a13d..b8cafeb0431721be7667b0647184ae74eaab6aa2 100644 (file)
@@ -390,28 +390,29 @@ static void ftsdc_setup_cfg(struct mmc_config *cfg, const char *name, int buswid
 
 static int ftsdc010_mmc_of_to_plat(struct udevice *dev)
 {
-#if CONFIG_IS_ENABLED(OF_REAL)
        struct ftsdc_priv *priv = dev_get_priv(dev);
        struct ftsdc010_chip *chip = &priv->chip;
 
-       chip->name = dev->name;
-       chip->ioaddr = dev_read_addr_ptr(dev);
-       chip->buswidth = dev_read_u32_default(dev, "bus-width", 4);
-       chip->priv = dev;
-       priv->fifo_depth = dev_read_u32_default(dev, "fifo-depth", 0);
-       priv->fifo_mode = dev_read_bool(dev, "fifo-mode");
-       if (dev_read_u32_array(dev, "clock-freq-min-max", priv->minmax, 2)) {
-               if (dev_read_u32(dev, "max-frequency", &priv->minmax[1]))
-                       return -EINVAL;
-
-               priv->minmax[0] = 400000;  /* 400 kHz */
-       } else {
-               debug("%s: 'clock-freq-min-max' property was deprecated.\n",
-               __func__);
+       if (CONFIG_IS_ENABLED(OF_REAL)) {
+               chip->name = dev->name;
+               chip->ioaddr = dev_read_addr_ptr(dev);
+               chip->buswidth = dev_read_u32_default(dev, "bus-width", 4);
+               chip->priv = dev;
+               priv->fifo_depth = dev_read_u32_default(dev, "fifo-depth", 0);
+               priv->fifo_mode = dev_read_bool(dev, "fifo-mode");
+               if (dev_read_u32_array(dev, "clock-freq-min-max", priv->minmax, 2)) {
+                       if (dev_read_u32(dev, "max-frequency", &priv->minmax[1]))
+                               return -EINVAL;
+
+                       priv->minmax[0] = 400000;  /* 400 kHz */
+               } else {
+                       debug("%s: 'clock-freq-min-max' property was deprecated.\n",
+                             __func__);
+               }
        }
-#endif
        chip->sclk = priv->minmax[1];
        chip->regs = chip->ioaddr;
+
        return 0;
 }
 
index fa297a0bc98a7bfff253a16e0be7abfaaed571e8..855c0e7af52c14273c1c9aa0bf8e11b5c7e6f748 100644 (file)
@@ -52,10 +52,12 @@ static uint rockchip_dwmmc_get_mmc_clk(struct dwmci_host *host, uint freq)
 
 static int rockchip_dwmmc_of_to_plat(struct udevice *dev)
 {
-#if CONFIG_IS_ENABLED(OF_REAL)
        struct rockchip_dwmmc_priv *priv = dev_get_priv(dev);
        struct dwmci_host *host = &priv->host;
 
+       if (!CONFIG_IS_ENABLED(OF_REAL))
+               return 0;
+
        host->name = dev->name;
        host->ioaddr = dev_read_addr_ptr(dev);
        host->buswidth = dev_read_u32_default(dev, "bus-width", 4);
@@ -95,7 +97,7 @@ static int rockchip_dwmmc_of_to_plat(struct udevice *dev)
                debug("%s: 'clock-freq-min-max' property was deprecated.\n",
                      __func__);
        }
-#endif
+
        return 0;
 }
 
index 5a72283dac2d162651f08e1a776857985b294b65..69c454a4ba86b029a781d2b4f86c3d6e895c3275 100644 (file)
@@ -883,13 +883,13 @@ static int rk3368_dmc_of_to_plat(struct udevice *dev)
 {
        int ret = 0;
 
-#if CONFIG_IS_ENABLED(OF_REAL)
-       struct rk3368_sdram_params *plat = dev_get_plat(dev);
+       if (CONFIG_IS_ENABLED(OF_REAL)) {
+               struct rk3368_sdram_params *plat = dev_get_plat(dev);
 
-       ret = regmap_init_mem(dev_ofnode(dev), &plat->map);
-       if (ret)
-               return ret;
-#endif
+               ret = regmap_init_mem(dev_ofnode(dev), &plat->map);
+               if (ret)
+                       return ret;
+       }
 
        return ret;
 }
index 38d25c8b780fe7377c68cdcba43299a1be1ae825..d9ed8adfcfd05a74b37e8a8abe1243957f67d306 100644 (file)
@@ -816,10 +816,12 @@ static int setup_sdram(struct udevice *dev)
 
 static int rk3188_dmc_of_to_plat(struct udevice *dev)
 {
-#if CONFIG_IS_ENABLED(OF_REAL)
        struct rk3188_sdram_params *params = dev_get_plat(dev);
        int ret;
 
+       if (!CONFIG_IS_ENABLED(OF_REAL))
+               return 0;
+
        /* rk3188 supports only one-channel */
        params->num_channels = 1;
        ret = dev_read_u32_array(dev, "rockchip,pctl-timing",
@@ -846,7 +848,6 @@ static int rk3188_dmc_of_to_plat(struct udevice *dev)
        ret = regmap_init_mem(dev_ofnode(dev), &params->map);
        if (ret)
                return ret;
-#endif
 
        return 0;
 }
index fd12008ed904abff007fe77d089615ba6571a868..30e9c3ddc45b04b073662eb51ebd6fe7977c8e09 100644 (file)
@@ -716,12 +716,14 @@ out:
 
 static int rk322x_dmc_of_to_plat(struct udevice *dev)
 {
-#if CONFIG_IS_ENABLED(OF_REAL)
        struct rk322x_sdram_params *params = dev_get_plat(dev);
        const void *blob = gd->fdt_blob;
        int node = dev_of_offset(dev);
        int ret;
 
+       if (!CONFIG_IS_ENABLED(OF_REAL))
+               return 0;
+
        params->num_channels = 1;
 
        ret = fdtdec_get_int_array(blob, node, "rockchip,pctl-timing",
@@ -748,7 +750,6 @@ static int rk322x_dmc_of_to_plat(struct udevice *dev)
        ret = regmap_init_mem(dev_ofnode(dev), &params->map);
        if (ret)
                return ret;
-#endif
 
        return 0;
 }
index 2cb034f263fec47c9d1afc1f952dadefa667c076..f3e4a2808ab7ca19876642fcbd335a6e44007e08 100644 (file)
@@ -973,10 +973,12 @@ static int setup_sdram(struct udevice *dev)
 
 static int rk3288_dmc_of_to_plat(struct udevice *dev)
 {
-#if CONFIG_IS_ENABLED(OF_REAL)
        struct rk3288_sdram_params *params = dev_get_plat(dev);
        int ret;
 
+       if (!CONFIG_IS_ENABLED(OF_REAL))
+               return 0;
+
        /* Rk3288 supports dual-channel, set default channel num to 2 */
        params->num_channels = 2;
        ret = dev_read_u32_array(dev, "rockchip,pctl-timing",
@@ -1008,7 +1010,6 @@ static int rk3288_dmc_of_to_plat(struct udevice *dev)
        ret = regmap_init_mem(dev_ofnode(dev), &params->map);
        if (ret)
                return ret;
-#endif
 
        return 0;
 }
index c9631af2643763eff047904df890bde82f9fdf90..ce33fbbd7a6d5f95f52d43cbdaaad7ab3c56f2ac 100644 (file)
@@ -3013,10 +3013,12 @@ static int sdram_init(struct dram_info *dram,
 
 static int rk3399_dmc_of_to_plat(struct udevice *dev)
 {
-#if CONFIG_IS_ENABLED(OF_REAL)
        struct rockchip_dmc_plat *plat = dev_get_plat(dev);
        int ret;
 
+       if (!CONFIG_IS_ENABLED(OF_REAL))
+               return 0;
+
        ret = dev_read_u32_array(dev, "rockchip,sdram-params",
                                 (u32 *)&plat->sdram_params,
                                 sizeof(plat->sdram_params) / sizeof(u32));
@@ -3029,7 +3031,6 @@ static int rk3399_dmc_of_to_plat(struct udevice *dev)
        if (ret)
                printf("%s: regmap failed %d\n", __func__, ret);
 
-#endif
        return 0;
 }
 
index e504e306fd74797ff2df6a18806fa62fc021ded2..8309a5301f2ab6e4d75c417bc7e3feac72e0aa8d 100644 (file)
@@ -193,31 +193,31 @@ static int conv_of_plat(struct udevice *dev)
 
 static int rockchip_spi_of_to_plat(struct udevice *bus)
 {
-#if CONFIG_IS_ENABLED(OF_REAL)
        struct rockchip_spi_plat *plat = dev_get_plat(bus);
        struct rockchip_spi_priv *priv = dev_get_priv(bus);
        int ret;
 
-       plat->base = dev_read_addr(bus);
+       if (CONFIG_IS_ENABLED(OF_REAL)) {
+               plat->base = dev_read_addr(bus);
 
-       ret = clk_get_by_index(bus, 0, &priv->clk);
-       if (ret < 0) {
-               debug("%s: Could not get clock for %s: %d\n", __func__,
-                     bus->name, ret);
-               return ret;
-       }
+               ret = clk_get_by_index(bus, 0, &priv->clk);
+               if (ret < 0) {
+                       debug("%s: Could not get clock for %s: %d\n", __func__,
+                             bus->name, ret);
+                       return ret;
+               }
 
-       plat->frequency =
-               dev_read_u32_default(bus, "spi-max-frequency", 50000000);
-       plat->deactivate_delay_us =
-               dev_read_u32_default(bus, "spi-deactivate-delay", 0);
-       plat->activate_delay_us =
-               dev_read_u32_default(bus, "spi-activate-delay", 0);
+               plat->frequency = dev_read_u32_default(bus, "spi-max-frequency",
+                                                      50000000);
+               plat->deactivate_delay_us =
+                       dev_read_u32_default(bus, "spi-deactivate-delay", 0);
+               plat->activate_delay_us =
+                       dev_read_u32_default(bus, "spi-activate-delay", 0);
 
-       debug("%s: base=%x, max-frequency=%d, deactivate_delay=%d\n",
-             __func__, (uint)plat->base, plat->frequency,
-             plat->deactivate_delay_us);
-#endif
+               debug("%s: base=%x, max-frequency=%d, deactivate_delay=%d\n",
+                     __func__, (uint)plat->base, plat->frequency,
+                     plat->deactivate_delay_us);
+       }
 
        return 0;
 }
index 655fb1407aac4fd7d3f32788dd35aa79467aa85b..f8ec312d715235669bf659bb7ead0188b6249ea1 100644 (file)
@@ -176,11 +176,11 @@ static int spi_child_post_bind(struct udevice *dev)
 
 static int spi_post_probe(struct udevice *bus)
 {
-#if CONFIG_IS_ENABLED(OF_REAL)
-       struct dm_spi_bus *spi = dev_get_uclass_priv(bus);
+       if (CONFIG_IS_ENABLED(OF_REAL)) {
+               struct dm_spi_bus *spi = dev_get_uclass_priv(bus);
 
-       spi->max_hz = dev_read_u32_default(bus, "spi-max-frequency", 0);
-#endif
+               spi->max_hz = dev_read_u32_default(bus, "spi-max-frequency", 0);
+       }
 #if defined(CONFIG_NEEDS_MANUAL_RELOC)
        struct dm_spi_ops *ops = spi_get_ops(bus);
        static int reloc_done;
index 96621479105b63d33b441102593d3ded913942d6..62eacb9868907dc391fc87bd137b00dc42d4348e 100644 (file)
@@ -55,8 +55,7 @@ ulong timer_get_boot_us(void)
                /* The timer is available */
                rate = timer_get_rate(gd->timer);
                timer_get_count(gd->timer, &ticks);
-#if CONFIG_IS_ENABLED(OF_REAL)
-       } else if (ret == -EAGAIN) {
+       } else if (CONFIG_IS_ENABLED(OF_REAL) && ret == -EAGAIN) {
                /* We have been called so early that the DM is not ready,... */
                ofnode node = offset_to_ofnode(-1);
                struct rk_timer *timer = NULL;
@@ -79,7 +78,6 @@ ulong timer_get_boot_us(void)
                        debug("%s: could not read clock-frequency\n", __func__);
                        return 0;
                }
-#endif
        } else {
                return 0;
        }
@@ -100,13 +98,13 @@ static u64 rockchip_timer_get_count(struct udevice *dev)
 
 static int rockchip_clk_of_to_plat(struct udevice *dev)
 {
-#if CONFIG_IS_ENABLED(OF_REAL)
-       struct rockchip_timer_priv *priv = dev_get_priv(dev);
+       if (CONFIG_IS_ENABLED(OF_REAL)) {
+               struct rockchip_timer_priv *priv = dev_get_priv(dev);
 
-       priv->timer = dev_read_addr_ptr(dev);
-       if (!priv->timer)
-               return -ENOENT;
-#endif
+               priv->timer = dev_read_addr_ptr(dev);
+               if (!priv->timer)
+                       return -ENOENT;
+       }
 
        return 0;
 }
index 52bddb9654f0636bcf627da62f52f59e0487f767..6ea9e39e126c517a5c9d734eb02fa18c9127ba26 100644 (file)
@@ -50,27 +50,29 @@ unsigned long notrace timer_get_rate(struct udevice *dev)
 
 static int timer_pre_probe(struct udevice *dev)
 {
-#if CONFIG_IS_ENABLED(OF_REAL)
-       struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev);
-       struct clk timer_clk;
-       int err;
-       ulong ret;
+       if (CONFIG_IS_ENABLED(OF_REAL)) {
+               struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev);
+               struct clk timer_clk;
+               int err;
+               ulong ret;
 
-       /* It is possible that a timer device has a null ofnode */
-       if (!dev_has_ofnode(dev))
-               return 0;
+               /*
+                * It is possible that a timer device has a null ofnode
+                */
+               if (!dev_has_ofnode(dev))
+                       return 0;
 
-       err = clk_get_by_index(dev, 0, &timer_clk);
-       if (!err) {
-               ret = clk_get_rate(&timer_clk);
-               if (IS_ERR_VALUE(ret))
-                       return ret;
-               uc_priv->clock_rate = ret;
-       } else {
-               uc_priv->clock_rate =
-                       dev_read_u32_default(dev, "clock-frequency", 0);
+               err = clk_get_by_index(dev, 0, &timer_clk);
+               if (!err) {
+                       ret = clk_get_rate(&timer_clk);
+                       if (IS_ERR_VALUE(ret))
+                               return ret;
+                       uc_priv->clock_rate = ret;
+               } else {
+                       uc_priv->clock_rate =
+                               dev_read_u32_default(dev, "clock-frequency", 0);
+               }
        }
-#endif
 
        return 0;
 }
@@ -136,23 +138,23 @@ int notrace dm_timer_init(void)
        if (gd->dm_root == NULL)
                return -EAGAIN;
 
-#if CONFIG_IS_ENABLED(OF_REAL)
-       /* Check for a chosen timer to be used for tick */
-       node = ofnode_get_chosen_node("tick-timer");
-
-       if (ofnode_valid(node) &&
-           uclass_get_device_by_ofnode(UCLASS_TIMER, node, &dev)) {
-               /*
-                * If the timer is not marked to be bound before
-                * relocation, bind it anyway.
-                */
-               if (!lists_bind_fdt(dm_root(), node, &dev, false)) {
-                       ret = device_probe(dev);
-                       if (ret)
-                               return ret;
+       if (CONFIG_IS_ENABLED(OF_REAL)) {
+               /* Check for a chosen timer to be used for tick */
+               node = ofnode_get_chosen_node("tick-timer");
+
+               if (ofnode_valid(node) &&
+                   uclass_get_device_by_ofnode(UCLASS_TIMER, node, &dev)) {
+                       /*
+                        * If the timer is not marked to be bound before
+                        * relocation, bind it anyway.
+                        */
+                       if (!lists_bind_fdt(dm_root(), node, &dev, false)) {
+                               ret = device_probe(dev);
+                               if (ret)
+                                       return ret;
+                       }
                }
        }
-#endif
 
        if (!dev) {
                /* Fall back to the first available timer */