From de4cd35477ff6d93c98bde950cd1320dfd0b76db Mon Sep 17 00:00:00 2001 From: Kenji Chen Date: Tue, 21 Oct 2014 08:03:13 +0800 Subject: CHERRY-PICK: EC: Ensure the udelay function waits at least the time indicated. Udelay function might get delay less than the time indicated by the input parameter. udelay(4) sometimes get the tick like, 6->7->7-> 8->8->9->A and then the udelay return. But, the sampling point of 6 could be at the end of 6(close to 7) and the point of A could be right at the beginning of A(close to A). This function could get delay from (us - 1) to (us + 1). This change is to ensure the delay at least over the parameter, us. BRANCH=master BUG=None TEST=Build an EC FW iamge and run on Rambi to ensure at the time duration indicated by the parameter is elaspsed and satisfied. Signed-off-by: Kenji Chen Original-Change-Id: I797f80c577d7e29e75a304aec1e02d2c750f8a23 Reviewed-on: https://chromium-review.googlesource.com/224660 Reviewed-by: Randall Spangler Reviewed-by: Mohammed Habibulla Change-Id: Iacd0485511e9e01325bd7b11943880ea067be795 Reviewed-on: https://chromium-review.googlesource.com/229154 Reviewed-by: Mohammed Habibulla Commit-Queue: Mohammed Habibulla Tested-by: Mohammed Habibulla --- common/timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/timer.c b/common/timer.c index bc36c87c49..96e582575c 100644 --- a/common/timer.c +++ b/common/timer.c @@ -109,7 +109,7 @@ void udelay(unsigned us) * subtraction below can overflow. That's acceptable, because the * watchdog timer would have tripped long before that anyway. */ - while (__hw_clock_source_read() - t0 < us) + while (__hw_clock_source_read() - t0 <= us) ; } #endif -- cgit v1.2.1