From patchwork Fri May 25 06:19:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Lin X-Patchwork-Id: 10426461 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 55FF9602D8 for ; Fri, 25 May 2018 06:19:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4632829556 for ; Fri, 25 May 2018 06:19:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 39C652955A; Fri, 25 May 2018 06:19:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_WEB autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB91E29556 for ; Fri, 25 May 2018 06:19:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935438AbeEYGTl (ORCPT ); Fri, 25 May 2018 02:19:41 -0400 Received: from lucky1.263xmail.com ([211.157.147.131]:60187 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932304AbeEYGTk (ORCPT ); Fri, 25 May 2018 02:19:40 -0400 Received: from shawn.lin?rock-chips.com (unknown [192.168.167.140]) by lucky1.263xmail.com (Postfix) with ESMTP id 4894B96B76; Fri, 25 May 2018 14:19:37 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id A25D93C1; Fri, 25 May 2018 14:19:36 +0800 (CST) X-IP-DOMAINF: 1 X-RL-SENDER: shawn.lin@rock-chips.com X-FST-TO: ulf.hansson@linaro.org X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: shawn.lin@rock-chips.com X-UNIQUE-TAG: X-ATTACHMENT-NUM: 0 X-SENDER: lintao@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 28263WENLO9; Fri, 25 May 2018 14:19:37 +0800 (CST) From: Shawn Lin To: Ulf Hansson Cc: linux-mmc@vger.kernel.org, Martin Hicks , Shawn Lin Subject: [PATCH 10/11] mmc: core: Use mmc_poll_for_busy() for polling busy in mmc_do_erase() Date: Fri, 25 May 2018 14:19:17 +0800 Message-Id: <1527229157-217329-1-git-send-email-shawn.lin@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1527228930-216210-1-git-send-email-shawn.lin@rock-chips.com> References: <1527228930-216210-1-git-send-email-shawn.lin@rock-chips.com> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Now mmc_poll_for_busy() could replace the whole bunch of code in mmc_do_erase() when polling for busy. Signed-off-by: Shawn Lin --- drivers/mmc/core/core.c | 40 ++-------------------------------------- 1 file changed, 2 insertions(+), 38 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 2cb8450..a944175 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1968,7 +1968,6 @@ static int mmc_do_erase(struct mmc_card *card, unsigned int from, struct mmc_command cmd = {}; unsigned int qty = 0, busy_timeout = 0; bool use_r1b_resp = false; - unsigned long timeout; int err; mmc_retune_hold(card->host); @@ -2059,43 +2058,8 @@ static int mmc_do_erase(struct mmc_card *card, unsigned int from, goto out; } - if (mmc_host_is_spi(card->host)) - goto out; - - /* - * In case of when R1B + MMC_CAP_WAIT_WHILE_BUSY is used, the polling - * shall be avoided. - */ - if ((card->host->caps & MMC_CAP_WAIT_WHILE_BUSY) && use_r1b_resp) - goto out; - - timeout = jiffies + msecs_to_jiffies(busy_timeout); - do { - memset(&cmd, 0, sizeof(struct mmc_command)); - cmd.opcode = MMC_SEND_STATUS; - cmd.arg = card->rca << 16; - cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; - /* Do not retry else we can't see errors */ - err = mmc_wait_for_cmd(card->host, &cmd, 0); - if (err || (cmd.resp[0] & 0xFFF9A000)) { - pr_err("error %d requesting status %#x\n", - err, cmd.resp[0]); - err = -EIO; - goto out; - } - - /* Timeout if the device never becomes ready for data and - * never leaves the program state. - */ - if (time_after(jiffies, timeout)) { - pr_err("%s: Card stuck in programming state! %s\n", - mmc_hostname(card->host), __func__); - err = -EIO; - goto out; - } - - } while (!(cmd.resp[0] & R1_READY_FOR_DATA) || - (R1_CURRENT_STATE(cmd.resp[0]) == R1_STATE_PRG)); + err = mmc_poll_for_busy(card, busy_timeout, true, false, + use_r1b_resp, 0, false); out: mmc_retune_release(card->host); return err;