From patchwork Thu Aug 25 18:36:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 74701 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp981501qga; Thu, 25 Aug 2016 11:36:43 -0700 (PDT) X-Received: by 10.194.175.106 with SMTP id bz10mr9965105wjc.42.1472150203424; Thu, 25 Aug 2016 11:36:43 -0700 (PDT) Return-Path: Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id p145si15564213wme.109.2016.08.25.11.36.43; Thu, 25 Aug 2016 11:36:43 -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 D207C4B71E; Thu, 25 Aug 2016 20:36:41 +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 g_-IuAiH6O4u; Thu, 25 Aug 2016 20:36:41 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 46D3B4B660; Thu, 25 Aug 2016 20:36:41 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 42FD94B660 for ; Thu, 25 Aug 2016 20:36:38 +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 VpHvv1okNGir for ; Thu, 25 Aug 2016 20:36:38 +0200 (CEST) Received: from arroyo.ext.ti.com (arroyo.ext.ti.com [198.47.19.12]) by theia.denx.de (Postfix) with ESMTPS id BA53B4B62B for ; Thu, 25 Aug 2016 20:36:37 +0200 (CEST) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id u7PIaTml004503; Thu, 25 Aug 2016 13:36:29 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id u7PIaTxa030029; Thu, 25 Aug 2016 13:36:29 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.294.0; Thu, 25 Aug 2016 13:36:28 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id u7PIaS6L011977; Thu, 25 Aug 2016 13:36:28 -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 u7PIaS313543; Thu, 25 Aug 2016 13:36:28 -0500 (CDT) From: "Andrew F. Davis" To: Lokesh Vutla , Stefan Roese Date: Thu, 25 Aug 2016 13:36:28 -0500 Message-ID: <20160825183628.1774-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 ())