From patchwork Thu Aug 30 07:24:39 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?TWF0ZWogRnJhbsSNZcWha2lu?= X-Patchwork-Id: 180807 X-Patchwork-Delegate: marek.vasut@gmail.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 256FF2C013E for ; Thu, 30 Aug 2012 17:25:30 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7897B28085; Thu, 30 Aug 2012 09:25:24 +0200 (CEST) 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 YQ2csN9JFMr8; Thu, 30 Aug 2012 09:25:24 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5FB482807F; Thu, 30 Aug 2012 09:25:21 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2DE252807F for ; Thu, 30 Aug 2012 09:25:13 +0200 (CEST) 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 CKMEBAN-z26Q for ; Thu, 30 Aug 2012 09:24:59 +0200 (CEST) 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 xwall.hsl.eu (xwall.hsl.eu [193.169.48.45]) by theia.denx.de (Postfix) with ESMTPS id 7E38F2807E for ; Thu, 30 Aug 2012 09:24:52 +0200 (CEST) Received: from mailedge.hermes.si ([10.17.200.202]) by xwall.hsl.eu over TLS secured channel (TLSv1:AES128-SHA:128) with XWall v3.47k. ; Thu, 30 Aug 2012 09:24:40 +0200 Received: from MAIL.hermes.si (10.17.200.201) by MAILEDGE.hermes.si (10.17.200.202) with Microsoft SMTP Server (TLS) id 14.2.318.1; Thu, 30 Aug 2012 09:24:27 +0200 Received: from MAIL.hermes.si ([10.17.200.201]) by mail.hermes.si ([10.17.200.201]) with mapi id 14.02.0318.001; Thu, 30 Aug 2012 09:24:40 +0200 Thread-Topic: [PATCH] MUSB driver: Timeout is never detected as the while loop does not end Thread-Index: AQHNhXqIHwnb3R2xT0iMgItd1JnPNJdwcPgQgAGD+/A= References: <1346198876-31080-1-git-send-email-amartin@nvidia.com> <1346198876-31080-8-git-send-email-amartin@nvidia.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: From: =?iso-8859-2?Q?Matej=20Fran=E8e=B9kin?= To: "u-boot@lists.denx.de" Date: Thu, 30 Aug 2012 09:24:39 +0200 X-Assembled-By: XWall v3.47k. Message-ID: <6AB4CEAFA8401D4B880B2C9D8BEBA82D3533D5BD@mail.hermes.si> X-XWALL-BCKS: auto Mime-Version: 1.0 Cc: Marek Vasut Subject: [U-Boot] [PATCH] MUSB driver: Timeout is never detected as the while loop does not end 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 Timeout variable is decremented once more when while condition is not met. Following "if" does not detect correctly that timeout has occurred. Because of this bug the "usb start" command on AM335X-EVM board did not detect correctly that USB device was not attached. timeout = musb_cfg.timeout; while (timeout--) if (readb(&musbr->devctl) & MUSB_DEVCTL_HM) break; /* if musb core is not in host mode, then return */ if (!timeout) return -1; Signed-off-by: Matej Franceskin CC: Marek Vasut ? Acked-by: Tom Rini --- drivers/usb/musb/musb_hcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) if (!timeout) return -1; diff --git a/drivers/usb/musb/musb_hcd.c b/drivers/usb/musb/musb_hcd.c index 2df52c1..8d44c46 100644 --- a/drivers/usb/musb/musb_hcd.c +++ b/drivers/usb/musb/musb_hcd.c @@ -1113,7 +1113,7 @@ int usb_lowlevel_init(void) * should be a usb device connected. */ timeout = musb_cfg.timeout; - while (timeout--) + while (--timeout) if (readb(&musbr->devctl) & MUSB_DEVCTL_HM) break; /* if musb core is not in host mode, then return */