From patchwork Thu Jan 24 11:05:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Lin X-Patchwork-Id: 215313 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 D563D2C007C for ; Thu, 24 Jan 2013 22:06:35 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9061F4A08B; Thu, 24 Jan 2013 12:06:32 +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 2MSOXYyvHthN; Thu, 24 Jan 2013 12:06:32 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D49F14A08F; Thu, 24 Jan 2013 12:06:30 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9B6CA4A08F for ; Thu, 24 Jan 2013 12:06:28 +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 9g2WVrf+GCkW for ; Thu, 24 Jan 2013 12:06:27 +0100 (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 hqemgate03.nvidia.com (hqemgate03.nvidia.com [216.228.121.140]) by theia.denx.de (Postfix) with ESMTPS id 07FF94A08B for ; Thu, 24 Jan 2013 12:06:25 +0100 (CET) Received: from hqnvupgp05.nvidia.com (Not Verified[216.228.121.13]) by hqemgate03.nvidia.com id ; Thu, 24 Jan 2013 03:10:32 -0800 Received: from hqemhub03.nvidia.com ([172.17.108.22]) by hqnvupgp05.nvidia.com (PGP Universal service); Thu, 24 Jan 2013 03:06:15 -0800 X-PGP-Universal: processed; by hqnvupgp05.nvidia.com on Thu, 24 Jan 2013 03:06:15 -0800 Received: from hqnvemgw02.nvidia.com (172.16.227.111) by HQEMHUB03.nvidia.com (172.20.150.15) with Microsoft SMTP Server id 8.3.297.1; Thu, 24 Jan 2013 03:06:14 -0800 Received: from thelma.nvidia.com (Not Verified[172.16.212.77]) by hqnvemgw02.nvidia.com with MailMarshal (v6,7,2,8378) id ; Thu, 24 Jan 2013 03:06:15 -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 r0OB6BrH001434; Thu, 24 Jan 2013 03:06:12 -0800 (PST) From: Jim Lin To: , , Date: Thu, 24 Jan 2013 19:05:55 +0800 Message-ID: <1359025555-15119-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 v3] 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 --- Changes in v2: - use do-while and get_timer to count timeout. Changes in v3: - revert original udelay(10000); for safety. common/main.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common/main.c b/common/main.c index b145f85..dcd2a42 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,10 @@ int abortboot(int bootdelay) #endif while ((bootdelay > 0) && (!abort)) { - int i; - --bootdelay; - /* delay 100 * 10ms */ - for (i=0; !abort && i<100; ++i) { + /* delay 1000 ms */ + ts = get_timer(0); + do { if (tstc()) { /* we got a key press */ abort = 1; /* don't auto boot */ bootdelay = 0; /* no more delay */ @@ -264,7 +264,7 @@ int abortboot(int bootdelay) break; } udelay(10000); - } + } while (!abort && get_timer(ts) < 1000); printf("\b\b\b%2d ", bootdelay); }