public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Andrew F. Davis <afd@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2] common/xyzModem.c: Fix delay timeout calculation
Date: Tue, 20 Sep 2016 10:39:49 -0500	[thread overview]
Message-ID: <20160920153949.11988-1-afd@ti.com> (raw)

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 <afd@ti.com>
---
 common/xyzModem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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 ())
-- 
2.9.3

             reply	other threads:[~2016-09-20 15:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-20 15:39 Andrew F. Davis [this message]
2016-09-23 19:57 ` [U-Boot] [PATCH v2] common/xyzModem.c: Fix delay timeout calculation Tom Rini
2016-09-27 16:27   ` Andrew F. Davis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160920153949.11988-1-afd@ti.com \
    --to=afd@ti.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox