From patchwork Tue Sep 20 15:39:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Davis X-Patchwork-Id: 76618 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp1552304qgf; Tue, 20 Sep 2016 08:40:02 -0700 (PDT) X-Received: by 10.194.135.76 with SMTP id pq12mr27872468wjb.114.1474386002146; Tue, 20 Sep 2016 08:40:02 -0700 (PDT) Return-Path: Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id s140si25734997wmd.57.2016.09.20.08.40.01; Tue, 20 Sep 2016 08:40: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 D131C4B951; Tue, 20 Sep 2016 17:40: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 61rxMyxEIrvh; Tue, 20 Sep 2016 17:40:00 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 160864B660; Tue, 20 Sep 2016 17:40:00 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5FB734B660 for ; Tue, 20 Sep 2016 17:39: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 q1EDaFWLGcFz for ; Tue, 20 Sep 2016 17:39:56 +0200 (CEST) Received: from bear.ext.ti.com (bear.ext.ti.com [198.47.19.11]) by theia.denx.de (Postfix) with ESMTPS id E868A4B656 for ; Tue, 20 Sep 2016 17:39:55 +0200 (CEST) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id u8KFdoEl023419; Tue, 20 Sep 2016 10:39:50 -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 u8KFdoIE022739; Tue, 20 Sep 2016 10:39:50 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.294.0; Tue, 20 Sep 2016 10:39:49 -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 u8KFdntN008287; Tue, 20 Sep 2016 10:39:49 -0500 Received: from localhost (uda0226330.am.dhcp.ti.com [128.247.83.101]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id u8KFdn328470; Tue, 20 Sep 2016 10:39:49 -0500 (CDT) From: "Andrew F. Davis" To: Lokesh Vutla , Stefan Roese Date: Tue, 20 Sep 2016 10:39:49 -0500 Message-ID: <20160920153949.11988-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 v2] 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() thousands 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 | 4 ++-- 1 file changed, 2 insertions(+), 2 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..390abdc 100644 --- a/common/xyzModem.c +++ b/common/xyzModem.c @@ -73,9 +73,9 @@ 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 / DELAY)) { - udelay (DELAY); + mdelay (DELAY); counter++; } if (tstc ())