summaryrefslogtreecommitdiff
path: root/drivers/timer
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-08-07 16:24:06 +0300
committerSimon Glass <sjg@chromium.org>2021-09-25 18:46:15 +0300
commitdcfc42b12f95fecffbf4692854acd4193240d86a (patch)
tree0415ef0a2804ac9dff88bc8ecfd28cd39a740de2 /drivers/timer
parent62470afed14a598d36d055c60ccc3ffab6967dcc (diff)
downloadu-boot-dcfc42b12f95fecffbf4692854acd4193240d86a.tar.xz
treewide: Try to avoid the preprocessor with OF_REAL
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>
Diffstat (limited to 'drivers/timer')
-rw-r--r--drivers/timer/rockchip_timer.c16
-rw-r--r--drivers/timer/timer-uclass.c68
2 files changed, 42 insertions, 42 deletions
diff --git a/drivers/timer/rockchip_timer.c b/drivers/timer/rockchip_timer.c
index 9662147910..62eacb9868 100644
--- a/drivers/timer/rockchip_timer.c
+++ b/drivers/timer/rockchip_timer.c
@@ -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;
}
diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c
index 52bddb9654..6ea9e39e12 100644
--- a/drivers/timer/timer-uclass.c
+++ b/drivers/timer/timer-uclass.c
@@ -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 */