From mboxrd@z Thu Jan 1 00:00:00 1970 From: Philipp Tomsich Date: Mon, 11 Sep 2017 11:18:09 +0200 Subject: [U-Boot] [PATCH v2 03/19] dm: timer: handle being called before dm_root is ready In-Reply-To: <1505121512-23283-1-git-send-email-philipp.tomsich@theobroma-systems.com> References: <1505121512-23283-1-git-send-email-philipp.tomsich@theobroma-systems.com> Message-ID: <1505121512-23283-4-git-send-email-philipp.tomsich@theobroma-systems.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 Reviewed-by: Simon Glass Acked-by: Philipp Tomsich --- Changes in v2: None drivers/timer/timer-uclass.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c index 62d6f0b..45397b2 100644 --- a/drivers/timer/timer-uclass.c +++ b/drivers/timer/timer-uclass.c @@ -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"); -- 2.1.4