From patchwork Wed Jan 23 06:37:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Lin X-Patchwork-Id: 214810 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 2EB662C0084 for ; Wed, 23 Jan 2013 17:43:46 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3EA094A0A2; Wed, 23 Jan 2013 07:43:44 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 utW1NOmdaWv0; Wed, 23 Jan 2013 07:43:44 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BB0AD4A098; Wed, 23 Jan 2013 07:43:40 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 568BB4A098 for ; Wed, 23 Jan 2013 07:43:38 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 e53hh4XeSIvK for ; Wed, 23 Jan 2013 07:43:36 +0100 (CET) X-Greylist: delayed 306 seconds by postgrey-1.27 at theia; Wed, 23 Jan 2013 07:43:34 CET X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from hqemgate04.nvidia.com (hqemgate04.nvidia.com [216.228.121.35]) by theia.denx.de (Postfix) with ESMTPS id 1DB954A097 for ; Wed, 23 Jan 2013 07:43:34 +0100 (CET) Received: from hqnvupgp07.nvidia.com (Not Verified[216.228.121.13]) by hqemgate04.nvidia.com id ; Tue, 22 Jan 2013 22:38:06 -0800 Received: from hqemhub01.nvidia.com ([172.17.108.22]) by hqnvupgp07.nvidia.com (PGP Universal service); Tue, 22 Jan 2013 22:38:07 -0800 X-PGP-Universal: processed; by hqnvupgp07.nvidia.com on Tue, 22 Jan 2013 22:38:07 -0800 Received: from hqnvemgw01.nvidia.com (172.20.150.20) by hqemhub01.nvidia.com (172.20.150.30) with Microsoft SMTP Server id 8.3.297.1; Tue, 22 Jan 2013 22:38:19 -0800 Received: from thelma.nvidia.com (Not Verified[172.16.212.77]) by hqnvemgw01.nvidia.com with MailMarshal (v6,7,2,8378) id ; Tue, 22 Jan 2013 22:39:19 -0800 Received: from jilin-desktop.nvidia.com (dhcp-10-19-108-200.nvidia.com [10.19.108.200]) by thelma.nvidia.com (8.13.8+Sun/8.8.8) with ESMTP id r0N6cGPx009104; Tue, 22 Jan 2013 22:38:17 -0800 (PST) From: Jim Lin To: , Date: Wed, 23 Jan 2013 14:37:14 +0800 Message-ID: <1358923034-2727-1-git-send-email-jilin@nvidia.com> X-Mailer: git-send-email 1.7.3 MIME-Version: 1.0 Cc: trini@ti.com, twarren@nvidia.com Subject: [U-Boot] [PATCH 1/1] console: USB: KBD: Fix incorrect autoboot timeout X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Autoboot timeout defined by CONFIG_BOOTDELAY will not be accurate if CONFIG_USB_KEYBOARD and CONFIG_SYS_USB_EVENT_POLL are defined in configuration file and when tstc() function for checking key pressed takes longer time than 10 ms (e.g., 50 ms) to finish. Signed-off-by: Jim Lin --- common/main.c | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-) diff --git a/common/main.c b/common/main.c index b145f85..8cdfb8b 100644 --- a/common/main.c +++ b/common/main.c @@ -225,6 +225,7 @@ static inline int abortboot(int bootdelay) { int abort = 0; + unsigned long ts; #ifdef CONFIG_MENUPROMPT printf(CONFIG_MENUPROMPT); @@ -248,11 +249,13 @@ int abortboot(int bootdelay) #endif while ((bootdelay > 0) && (!abort)) { - int i; + int i, j; --bootdelay; /* delay 100 * 10ms */ - for (i=0; !abort && i<100; ++i) { + j = 100; + for (i = 0; !abort && i < j; ++i) { + ts = get_timer(0); if (tstc()) { /* we got a key press */ abort = 1; /* don't auto boot */ bootdelay = 0; /* no more delay */ @@ -263,7 +266,11 @@ int abortboot(int bootdelay) # endif break; } - udelay(10000); + ts = get_timer(ts); + if (ts < 10) + mdelay(10 - ts); + else + j = 1000 / (int) ts; } printf("\b\b\b%2d ", bootdelay);