From patchwork Thu Aug 25 18:43:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 74703 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp984461qga; Thu, 25 Aug 2016 11:44:02 -0700 (PDT) X-Received: by 10.28.27.143 with SMTP id b137mr31885762wmb.12.1472150642445; Thu, 25 Aug 2016 11:44:02 -0700 (PDT) Return-Path: Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id u4si33001719wmf.121.2016.08.25.11.44.01; Thu, 25 Aug 2016 11:44:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) client-ip=85.214.87.163; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5A2124B979; Thu, 25 Aug 2016 20:44:00 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Gf2NF08ZyEAX; Thu, 25 Aug 2016 20:43:59 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 762B34B68A; Thu, 25 Aug 2016 20:43:59 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7128D4B68A for ; Thu, 25 Aug 2016 20:43:56 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DyK-F4ABPn2L for ; Thu, 25 Aug 2016 20:43:56 +0200 (CEST) Received: from comal.ext.ti.com (comal.ext.ti.com [198.47.26.152]) by theia.denx.de (Postfix) with ESMTPS id DF90C4B660 for ; Thu, 25 Aug 2016 20:43:55 +0200 (CEST) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id u7PIhZM0017503; Thu, 25 Aug 2016 13:43:35 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id u7PIhYls010061; Thu, 25 Aug 2016 13:43:34 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.294.0; Thu, 25 Aug 2016 13:43:34 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id u7PIhYrW021297; Thu, 25 Aug 2016 13:43:34 -0500 Received: from localhost (uda0226330.am.dhcp.ti.com [128.247.83.52]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id u7PIhY313913; Thu, 25 Aug 2016 13:43:34 -0500 (CDT) From: "Andrew F. Davis" To: Lokesh Vutla , Stefan Roese Date: Thu, 25 Aug 2016 13:43:33 -0500 Message-ID: <20160825184333.2296-1-afd@ti.com> X-Mailer: git-send-email 2.9.3 MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH] common/xyzModem.c: Fix delay timeout calculation X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" When waiting for input in CYGACC_COMM_IF_GETC_TIMEOUT we delay 2 seconds by incrementing and checking a counter variable every 20 uSeconds. The overhead in the loop calling tstc() millions of times causes the timeout to be closer to 20 seconds. Delay longer per iteration to reduce overhead and bring the timeout back closer to the correct time. Signed-off-by: Andrew F. Davis --- common/xyzModem.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) -- 2.9.3 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot diff --git a/common/xyzModem.c b/common/xyzModem.c index 5656aac..c3f2afc 100644 --- a/common/xyzModem.c +++ b/common/xyzModem.c @@ -71,11 +71,10 @@ typedef int cyg_int32; static int CYGACC_COMM_IF_GETC_TIMEOUT (char chan, char *c) { -#define DELAY 20 unsigned long counter = 0; - while (!tstc () && (counter < xyzModem_CHAR_TIMEOUT * 1000 / DELAY)) + while (!tstc () && (counter < xyzModem_CHAR_TIMEOUT)) { - udelay (DELAY); + mdelay (1); counter++; } if (tstc ())