[U-Boot] [PATCH] drivers: uclass: timer: rename timer_init() to dm_timer_init()

Mugunthan V N mugunthanvnm at ti.com
Sat Jan 16 17:49:23 CET 2016


Rename timer_init() to dm_timer_init() and remove dm_timer_init()
in lib/time.c as

* timer_init is called from board_f.c or board_r.c on different
  architectures which may result causes timer devices to be
  probed twice.
* lib/time.c dm_timer_init() does nothing other than calling
  timer_init().

Also remove reinitializing of ret in timer_init().

Signed-off-by: Mugunthan V N <mugunthanvnm at ti.com>
---

Tested this patch on dra74x evm. and pushed a branch [2].

[1] - http://pastebin.ubuntu.com/14524076/
[2] - git://git.ti.com/~mugunthanvnm/ti-u-boot/mugunth-ti-u-boot.git dm-timer-fix

---
 drivers/timer/timer-uclass.c | 7 +++++--
 include/timer.h              | 9 +++++++++
 lib/time.c                   | 8 --------
 3 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c
index 053411f..83d1a35 100644
--- a/drivers/timer/timer-uclass.c
+++ b/drivers/timer/timer-uclass.c
@@ -68,13 +68,16 @@ u64 timer_conv_64(u32 count)
 	return ((u64)gd->timebase_h << 32) | gd->timebase_l;
 }
 
-int timer_init(void)
+int notrace dm_timer_init(void)
 {
 	const void *blob = gd->fdt_blob;
 	struct udevice *dev = NULL;
 	int node;
 	int ret;
 
+	if (gd->timer)
+		return 0;
+
 	/* Check for a chosen timer to be used for tick */
 	node = fdtdec_get_chosen_node(blob, "tick-timer");
 	if (node < 0) {
@@ -92,7 +95,7 @@ int timer_init(void)
 			 */
 			if (node > 0 &&
 			    !lists_bind_fdt(gd->dm_root, blob, node, &dev)) {
-				int ret = device_probe(dev);
+				ret = device_probe(dev);
 				if (ret)
 					return ret;
 			}
diff --git a/include/timer.h b/include/timer.h
index 7fee17e..f14725c 100644
--- a/include/timer.h
+++ b/include/timer.h
@@ -8,6 +8,15 @@
 #define _TIMER_H_
 
 /*
+ * dm_timer_init - initialize a timer for time keeping. On success
+ * initializes gd->timer so that lib/timer can use it for future
+ * referrence.
+ *
+ * @return - 0 on success or error number
+ */
+int dm_timer_init(void);
+
+/*
  * timer_conv_64 - convert 32-bit counter value to 64-bit
  *
  * @count: 32-bit counter value
diff --git a/lib/time.c b/lib/time.c
index d4060f1..e9f6861 100644
--- a/lib/time.c
+++ b/lib/time.c
@@ -41,14 +41,6 @@ extern unsigned long __weak timer_read_counter(void);
 #endif
 
 #ifdef CONFIG_TIMER
-static int notrace dm_timer_init(void)
-{
-	if (!gd->timer)
-		return timer_init();
-
-	return 0;
-}
-
 ulong notrace get_tbclk(void)
 {
 	int ret;
-- 
2.7.0.rc3



More information about the U-Boot mailing list