From patchwork Fri May 25 06:17:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Lin X-Patchwork-Id: 10426447 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 8958A602D8 for ; Fri, 25 May 2018 06:17:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7AA8828662 for ; Fri, 25 May 2018 06:17:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F7E029548; Fri, 25 May 2018 06:17:46 +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 10F2228662 for ; Fri, 25 May 2018 06:17:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752839AbeEYGRp (ORCPT ); Fri, 25 May 2018 02:17:45 -0400 Received: from lucky1.263xmail.com ([211.157.147.133]:45642 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752085AbeEYGRp (ORCPT ); Fri, 25 May 2018 02:17:45 -0400 Received: from shawn.lin?rock-chips.com (unknown [192.168.167.13]) by lucky1.263xmail.com (Postfix) with ESMTP id 2E944956B8; Fri, 25 May 2018 14:17:42 +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 A18EC3BE; Fri, 25 May 2018 14:17:41 +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 12096WJO2GO; Fri, 25 May 2018 14:17:42 +0800 (CST) From: Shawn Lin To: Ulf Hansson Cc: linux-mmc@vger.kernel.org, Martin Hicks , Shawn Lin Subject: [PATCH 03/11] mmc: core: Rename and reorganize mmc_switch_status_error() Date: Fri, 25 May 2018 14:17:23 +0800 Message-Id: <1527229043-216987-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 Rename mmc_switch_status_error() to mmc_send_status_error(), and add check_switch_err in order to prepare for using it for other places. No functional change intended. Signed-off-by: Shawn Lin --- drivers/mmc/core/mmc_ops.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index 4d73db4..6e8826e 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -411,18 +411,21 @@ int mmc_spi_set_crc(struct mmc_host *host, int use_crc) return err; } -static int mmc_switch_status_error(struct mmc_host *host, u32 status) +static int mmc_send_status_error(struct mmc_host *host, u32 status, + bool check_switch_err) { - if (mmc_host_is_spi(host)) { - if (status & R1_SPI_ILLEGAL_COMMAND) - return -EBADMSG; - } else { + if (check_switch_err) { + if (unlikely(mmc_host_is_spi(host))) + return (status & R1_SPI_ILLEGAL_COMMAND) ? + -EBADMSG : 0; + if (status & 0xFDFFA000) pr_warn("%s: unexpected status %#x after switch\n", mmc_hostname(host), status); if (status & R1_SWITCH_ERROR) return -EBADMSG; } + return 0; } @@ -438,7 +441,7 @@ int __mmc_switch_status(struct mmc_card *card, bool crc_err_fatal) if (err) return err; - return mmc_switch_status_error(card->host, status); + return mmc_send_status_error(card->host, status, true); } int mmc_switch_status(struct mmc_card *card) @@ -493,7 +496,7 @@ static int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms, } else if (err) { return err; } else { - err = mmc_switch_status_error(host, status); + err = mmc_send_status_error(host, status, true); if (err) return err; busy = R1_CURRENT_STATE(status) == R1_STATE_PRG;