From patchwork Fri Jul 8 10:58:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 71670 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp385380qgy; Fri, 8 Jul 2016 03:57:32 -0700 (PDT) X-Received: by 10.28.209.14 with SMTP id i14mr2808038wmg.95.1467975452727; Fri, 08 Jul 2016 03:57:32 -0700 (PDT) Return-Path: Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id z206si2333022wmc.86.2016.07.08.03.57.32; Fri, 08 Jul 2016 03:57:32 -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; dkim=neutral (body hash did not verify) header.i=@nifty.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 5F8FF4B94B; Fri, 8 Jul 2016 12:57:31 +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 SkW18Q3X4OHC; Fri, 8 Jul 2016 12:57:30 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 39DD14B7FB; Fri, 8 Jul 2016 12:57:30 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BD0DC4B7FB for ; Fri, 8 Jul 2016 12:57:26 +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 gM-r-2cu9Vda for ; Fri, 8 Jul 2016 12:57:26 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 IN_IX_MANITU=4.35 (only DNSBL check requested) Received: from conuserg-10.nifty.com (conuserg-10.nifty.com [210.131.2.77]) by theia.denx.de (Postfix) with ESMTPS id 08E284B7EB for ; Fri, 8 Jul 2016 12:57:22 +0200 (CEST) Received: from beagle.diag.org (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-10.nifty.com with ESMTP id u68AuwRG017129; Fri, 8 Jul 2016 19:56:58 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com u68AuwRG017129 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1467975419; bh=NibWoxYwjB+swvaS7NiQMsYxJvqfPzJu3jWQNisYyYk=; h=From:To:Cc:Subject:Date:From; b=E1esMwLoEOoGNXnoPDSJkvQRQfIHGAKNCWsj1jY6zoxnz9MYCmjivnaigheh+Yoit PJkhXXcUvfGu61/vqkQ+N/+T4H4SFry04YWmlwxub7UDR/Iynv1/vS+d669Y0Citfh HZ3IGErBu56L/km/0GgwwwnKn8lS0Wz32YxluoqzYxqq3W1eDsSq+UBBRjcDXRsJoV 6gT2Z3M7+NO1UE15qYaZ+s0qJCydacElp5qxcuQoJKt8ZhwMsCVi38YYKQlKWl4Sg+ HQsQyE4KpG3aHXlt3YmzxInIHiBKV9ogO1XAJ0djfbPqj9F9ooESeOEX4gSnncP5ZW 01nFzfaS9b8VA== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Fri, 8 Jul 2016 19:58:24 +0900 Message-Id: <1467975504-15761-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 1.9.1 Cc: Pantelis Antoniou Subject: [U-Boot] [PATCH] mmc: sdhci: clean up time out detection 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The current timeout detection logic is not very nice; it calls get_timer(start) in the while() loop, and then calls it again after the loop to check if a timeout error happened. Because of the time difference between the two calls of get_time(), the reason detected after the loop may not be really true. Signed-off-by: Masahiro Yamada --- drivers/mmc/sdhci.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) -- 1.9.1 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index 604f18d..0a1882d 100644 --- a/drivers/mmc/sdhci.c +++ b/drivers/mmc/sdhci.c @@ -243,17 +243,17 @@ static int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd, stat = sdhci_readl(host, SDHCI_INT_STATUS); if (stat & SDHCI_INT_ERROR) break; - } while (((stat & mask) != mask) && - (get_timer(start) < SDHCI_READ_STATUS_TIMEOUT)); - if (get_timer(start) >= SDHCI_READ_STATUS_TIMEOUT) { - if (host->quirks & SDHCI_QUIRK_BROKEN_R1B) - return 0; - else { - printf("%s: Timeout for status update!\n", __func__); - return TIMEOUT; + if (get_timer(start) >= SDHCI_READ_STATUS_TIMEOUT) { + if (host->quirks & SDHCI_QUIRK_BROKEN_R1B) { + return 0; + } else { + printf("%s: Timeout for status update!\n", + __func__); + return TIMEOUT; + } } - } + } while ((stat & mask) != mask); if ((stat & (SDHCI_INT_ERROR | mask)) == mask) { sdhci_cmd_done(host, cmd);