]> git.sur5r.net Git - u-boot/commitdiff
dm: timer: handle being called before dm_root is ready
authorPhilipp Tomsich <philipp.tomsich@theobroma-systems.com>
Mon, 11 Sep 2017 20:04:11 +0000 (22:04 +0200)
committerPhilipp Tomsich <philipp.tomsich@theobroma-systems.com>
Mon, 18 Sep 2017 18:40:33 +0000 (20:40 +0200)
When used with bootstage recording, dm_timer_init may be called
surprisingly early: i.e. before dm_root is ready. To deal with
this case, we explicitly check for this condition and return
-EAGAIN to the caller (refer to drivers/timer/rockchip_timer.c
for a case where this is needed/used).

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Acked-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
drivers/timer/timer-uclass.c

index 62d6f0b29a6e81cdb060c22cca17469b4c29ab36..45397b230f03c25ac3a39ede454a4a361bbf42e4 100644 (file)
@@ -92,6 +92,13 @@ int notrace dm_timer_init(void)
        if (gd->timer)
                return 0;
 
+       /*
+        * Directly access gd->dm_root to suppress error messages, if the
+        * virtual root driver does not yet exist.
+        */
+       if (gd->dm_root == NULL)
+               return -EAGAIN;
+
 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
        /* Check for a chosen timer to be used for tick */
        node = ofnode_get_chosen_node("tick-timer");