From patchwork Wed May 30 02:11:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Lin X-Patchwork-Id: 10437503 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 7F5DB602BF for ; Wed, 30 May 2018 02:12:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C36528892 for ; Wed, 30 May 2018 02:12:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 60AF028895; Wed, 30 May 2018 02:12:00 +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 0A81E28892 for ; Wed, 30 May 2018 02:12:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755348AbeE3CL7 (ORCPT ); Tue, 29 May 2018 22:11:59 -0400 Received: from lucky1.263xmail.com ([211.157.147.131]:54078 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751713AbeE3CL6 (ORCPT ); Tue, 29 May 2018 22:11:58 -0400 Received: from shawn.lin?rock-chips.com (unknown [192.168.167.207]) by lucky1.263xmail.com (Postfix) with ESMTP id E4A4F96A26; Wed, 30 May 2018 10:11:55 +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 6045C3DC; Wed, 30 May 2018 10:11:55 +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 11617QLP21B; Wed, 30 May 2018 10:11:56 +0800 (CST) From: Shawn Lin To: Ulf Hansson Cc: linux-mmc@vger.kernel.org, Martin Hicks , Shawn Lin Subject: [PATCH v3 3/9] mmc: core: Propgate device status and assigning busy indicator in mmc_poll_for_busy() Date: Wed, 30 May 2018 10:11:52 +0800 Message-Id: <1527646312-133348-1-git-send-email-shawn.lin@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1527646231-132327-1-git-send-email-shawn.lin@rock-chips.com> References: <1527646231-132327-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 In preparation for reusing mmc_poll_for_busy() to avoid duplication of code for polling busy. No functional change intended. Signed-off-by: Shawn Lin --- Changes in v3: None Changes in v2: None drivers/mmc/core/mmc_ops.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index ee5f5ea..7e8be97 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -447,7 +447,8 @@ int mmc_switch_status(struct mmc_card *card) } static int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms, - bool send_status, bool retry_crc_err, bool use_r1b_resp) + bool send_status, bool retry_crc_err, bool use_r1b_resp, + u32 *resp_status, bool check_busy(u32 device_status)) { struct mmc_host *host = card->host; int err; @@ -461,6 +462,9 @@ static int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms, mmc_host_is_spi(host)) return 0; + if (WARN_ON(!check_busy)) + return 0; + /* We have an unspecified cmd timeout, use the fallback value. */ if (!timeout_ms) timeout_ms = MMC_OPS_TIMEOUT_MS; @@ -487,6 +491,9 @@ static int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms, busy = host->ops->card_busy(host); } else { err = mmc_send_status(card, &status); + /* Accumulate any response error bits seen */ + if (resp_status) + *resp_status |= status; if (retry_crc_err && err == -EILSEQ) { busy = true; } else if (err) { @@ -495,7 +502,7 @@ static int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms, err = mmc_switch_status_error(host, status); if (err) return err; - busy = R1_CURRENT_STATE(status) == R1_STATE_PRG; + busy = check_busy(status); } } @@ -510,6 +517,11 @@ static int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms, return 0; } +static inline bool mmc_switch_in_prg_state(u32 status) +{ + return R1_CURRENT_STATE(status) == R1_STATE_PRG; +} + /** * __mmc_switch - modify EXT_CSD register * @card: the MMC card associated with the data transfer @@ -577,7 +589,7 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, /* Let's try to poll to find out when the command is completed. */ err = mmc_poll_for_busy(card, timeout_ms, send_status, retry_crc_err, - use_r1b_resp); + use_r1b_resp, NULL, &mmc_switch_in_prg_state); if (err) goto out;